0

The first line of a .el file used to be

;;; foo.el - a foo package

Does it works if the magic comment is added after this?

;;; foo.el - a foo package
;;; -*- lexical-binding: t -*-

Or even later in the file?

tom
  • 1,302
  • 1
  • 16
  • 30

2 Answers2

2

The recommended way is

;;; <FILE> --- <DESCRIPTION>  -*- lexical-binding:t -*-
Stefan
  • 27,908
  • 4
  • 53
  • 82
1
  • C-hig (elisp) Using Lexical Binding
  • C-hig (emacs) Specifying File Variables

This must be in the first line. An exception is made for shell scripts (only), where it may alternatively be on the second line.

Note that, unlike other file-local vars, lexical-binding can only appear in this first-line listing.

phils
  • 71,335
  • 11
  • 153
  • 198
  • Could I do like this `;;; foo.el - a foo package -*- lexical-binding: t -*-` on the first line? – tom Mar 29 '16 at 09:04
  • Yes you can. Note that if you use `M-x add-file-local-variable-prop-line` it will do exactly that. – phils Mar 29 '16 at 09:39