diff options
| author | Stefan Monnier | 2025-04-08 13:10:30 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-04-08 13:10:30 -0400 |
| commit | 7ff674d7125452b0ce6a8d39cb667eacb90f3df2 (patch) | |
| tree | 0e5d464d6742dde21b0220395c023ce31fa5f208 | |
| parent | 646ccd5e67db701ed9f632492d1bfbe3f6110cb4 (diff) | |
| download | emacs-7ff674d7125452b0ce6a8d39cb667eacb90f3df2.tar.gz emacs-7ff674d7125452b0ce6a8d39cb667eacb90f3df2.zip | |
(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.
| -rw-r--r-- | lisp/files.el | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lisp/files.el b/lisp/files.el index 845168121c8..ad6047bd02d 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4290,24 +4290,31 @@ all the specified local variables, but ignores any settings of \"mode:\"." | |||
| 4290 | load-file-name)) | 4290 | load-file-name)) |
| 4291 | from | 4291 | from |
| 4292 | (abbreviate-file-name load-file-name)))) | 4292 | (abbreviate-file-name load-file-name)))) |
| 4293 | (display-warning | 4293 | (condition-case nil |
| 4294 | '(files missing-lexbind-cookie) | 4294 | (display-warning |
| 4295 | (format-message "Missing `lexical-binding' cookie in %S. | 4295 | `(files missing-lexbind-cookie |
| 4296 | ,(if (bufferp source) 'eval-buffer source)) | ||
| 4297 | (format-message "Missing `lexical-binding' cookie in %S. | ||
| 4296 | You can add one with `M-x %s RET'. | 4298 | You can add one with `M-x %s RET'. |
| 4297 | See `%s' and `%s' | 4299 | See `%s' and `%s' |
| 4298 | for more information." | 4300 | for more information." |
| 4299 | source | 4301 | source |
| 4300 | (buttonize "elisp-enable-lexical-binding" | 4302 | (buttonize "elisp-enable-lexical-binding" |
| 4301 | (lambda (_) | 4303 | (lambda (_) |
| 4302 | (pop-to-buffer | 4304 | (pop-to-buffer |
| 4303 | (if (bufferp source) source | 4305 | (if (bufferp source) source |
| 4304 | (find-file-noselect source))) | 4306 | (find-file-noselect source))) |
| 4305 | (call-interactively | 4307 | (call-interactively |
| 4306 | #'elisp-enable-lexical-binding)) | 4308 | #'elisp-enable-lexical-binding)) |
| 4307 | nil "mouse-2: Add cookie") | 4309 | nil "mouse-2: Add cookie") |
| 4308 | (funcall mib "(elisp)Selecting Lisp Dialect") | 4310 | (funcall mib "(elisp)Selecting Lisp Dialect") |
| 4309 | (funcall mib "(elisp)Converting to Lexical Binding")) | 4311 | (funcall mib "(elisp)Converting to Lexical Binding")) |
| 4310 | :warning))) | 4312 | :warning) |
| 4313 | ;; In various corner-case situations, `display-warning' may | ||
| 4314 | ;; fail (e.g. not yet defined, or can't be (auto)loaded), | ||
| 4315 | ;; so use a simple fallback that won't get in the way. | ||
| 4316 | (error | ||
| 4317 | (message "Missing `lexical-binding' cookie in %S" source))))) | ||
| 4311 | (default-toplevel-value 'lexical-binding))) | 4318 | (default-toplevel-value 'lexical-binding))) |
| 4312 | 4319 | ||
| 4313 | (setq internal--get-default-lexical-binding-function | 4320 | (setq internal--get-default-lexical-binding-function |