(internal--get-default-lexical-binding): Be more failsafe
* lisp/files.el (internal--get-default-lexical-binding): Try and avoid signaling an error. Make it easier to suppress the warning for a specific file.
This commit is contained in:
parent
646ccd5e67
commit
7ff674d712
1 changed files with 22 additions and 15 deletions
|
@ -4290,24 +4290,31 @@ all the specified local variables, but ignores any settings of \"mode:\"."
|
|||
load-file-name))
|
||||
from
|
||||
(abbreviate-file-name load-file-name))))
|
||||
(display-warning
|
||||
'(files missing-lexbind-cookie)
|
||||
(format-message "Missing `lexical-binding' cookie in %S.
|
||||
(condition-case nil
|
||||
(display-warning
|
||||
`(files missing-lexbind-cookie
|
||||
,(if (bufferp source) 'eval-buffer source))
|
||||
(format-message "Missing `lexical-binding' cookie in %S.
|
||||
You can add one with `M-x %s RET'.
|
||||
See `%s' and `%s'
|
||||
for more information."
|
||||
source
|
||||
(buttonize "elisp-enable-lexical-binding"
|
||||
(lambda (_)
|
||||
(pop-to-buffer
|
||||
(if (bufferp source) source
|
||||
(find-file-noselect source)))
|
||||
(call-interactively
|
||||
#'elisp-enable-lexical-binding))
|
||||
nil "mouse-2: Add cookie")
|
||||
(funcall mib "(elisp)Selecting Lisp Dialect")
|
||||
(funcall mib "(elisp)Converting to Lexical Binding"))
|
||||
:warning)))
|
||||
source
|
||||
(buttonize "elisp-enable-lexical-binding"
|
||||
(lambda (_)
|
||||
(pop-to-buffer
|
||||
(if (bufferp source) source
|
||||
(find-file-noselect source)))
|
||||
(call-interactively
|
||||
#'elisp-enable-lexical-binding))
|
||||
nil "mouse-2: Add cookie")
|
||||
(funcall mib "(elisp)Selecting Lisp Dialect")
|
||||
(funcall mib "(elisp)Converting to Lexical Binding"))
|
||||
:warning)
|
||||
;; In various corner-case situations, `display-warning' may
|
||||
;; fail (e.g. not yet defined, or can't be (auto)loaded),
|
||||
;; so use a simple fallback that won't get in the way.
|
||||
(error
|
||||
(message "Missing `lexical-binding' cookie in %S" source)))))
|
||||
(default-toplevel-value 'lexical-binding)))
|
||||
|
||||
(setq internal--get-default-lexical-binding-function
|
||||
|
|
Loading…
Add table
Reference in a new issue