summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-10-15 18:33:16 -0700
committerGlenn Morris <rgm@gnu.org>2013-10-15 18:33:16 -0700
commit012e2f9fdaf39b5f913b5560be3986e2bc599186 (patch)
tree495ab882e3b8e325b4e575539f51d63c256bd5c3 /lisp/files.el
parent62ad85e6af83a70576642219bef4d147410d2f73 (diff)
downloademacs-012e2f9fdaf39b5f913b5560be3986e2bc599186.tar.gz
* files.el (hack-local-variables): Warn about misplaced lexical-binding.
(hack-local-variables--warned-lexical): New. Fixes: debbugs:15616
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el22
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/files.el b/lisp/files.el
index ab62be295f0..cf3356014a1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3154,6 +3154,9 @@ DIR-NAME is the name of the associated directory. Otherwise it is nil."
(assq-delete-all (car elt) file-local-variables-alist)))
(push elt file-local-variables-alist)))))
+;; TODO? Warn once per file rather than once per session?
+(defvar hack-local-variables--warned-lexical nil)
+
(defun hack-local-variables (&optional mode-only)
"Parse and put into effect this buffer's local variables spec.
Uses `hack-local-variables-apply' to apply the variables.
@@ -3275,13 +3278,18 @@ local variables, but directory-local variables may still be applied."
"-minor\\'"
(setq val2 (downcase (symbol-name val)))))
(setq result (intern (concat val2 "-mode"))))
- (unless (eq var 'coding)
- (condition-case nil
- (push (cons (if (eq var 'eval)
- 'eval
- (indirect-variable var))
- val) result)
- (error nil)))))
+ (cond ((eq var 'coding))
+ ((eq var 'lexical-binding)
+ (unless hack-local-variables--warned-lexical
+ (setq hack-local-variables--warned-lexical t)
+ (display-warning :warning
+ "Specify `lexical-binding' on the first line, not at the end")))
+ (t
+ (ignore-errors
+ (push (cons (if (eq var 'eval)
+ 'eval
+ (indirect-variable var))
+ val) result))))))
(forward-line 1))))))))
;; Now we've read all the local variables.
;; If MODE-ONLY is non-nil, return whether the mode was specified.