summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2023-12-21 18:56:04 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2023-12-22 13:16:40 +0100
commitc638a40d88f6ca105babbf9078b086491b649797 (patch)
treea98bfc784f95b6eecbe262b01bc59d72e5e934e8 /lisp/emacs-lisp
parent9db1fe638ecfdd2d8dd32e3ee47f97c5ed3312c1 (diff)
downloademacs-c638a40d88f6ca105babbf9078b086491b649797.tar.gz
emacs-c638a40d88f6ca105babbf9078b086491b649797.tar.bz2
emacs-c638a40d88f6ca105babbf9078b086491b649797.zip
Ensure proper mode of *Compile-Log* buffer (bug#67920)
Reported by OGAWA Hirofumi. * lisp/emacs-lisp/bytecomp.el (displaying-byte-compile-warnings): Move most of the innards to... (bytecomp--displaying-warnings): ...this new function, for ease of maintenance. * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Wrap early warning about missing lexbind declaration in `displaying-byte-compile-warnings` so that it doesn't cause the creation of a compile-log buffer with the wrong mode.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el67
1 files changed, 35 insertions, 32 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d2f1e6886ef..6c5051d70c4 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1876,35 +1876,37 @@ It is too wide if it has any lines longer than the largest of
(defmacro displaying-byte-compile-warnings (&rest body)
(declare (debug (def-body)))
- `(let* ((--displaying-byte-compile-warnings-fn (lambda () ,@body))
- (warning-series-started
- (and (markerp warning-series)
- (eq (marker-buffer warning-series)
- (get-buffer byte-compile-log-buffer))))
- (byte-compile-form-stack byte-compile-form-stack))
- (if (or (eq warning-series 'byte-compile-warning-series)
- warning-series-started)
- ;; warning-series does come from compilation,
- ;; so don't bind it, but maybe do set it.
- (let (tem)
- ;; Log the file name. Record position of that text.
- (setq tem (byte-compile-log-file))
- (unless warning-series-started
- (setq warning-series (or tem 'byte-compile-warning-series)))
- (if byte-compile-debug
- (funcall --displaying-byte-compile-warnings-fn)
- (condition-case error-info
- (funcall --displaying-byte-compile-warnings-fn)
- (error (byte-compile-report-error error-info)))))
- ;; warning-series does not come from compilation, so bind it.
- (let ((warning-series
- ;; Log the file name. Record position of that text.
- (or (byte-compile-log-file) 'byte-compile-warning-series)))
- (if byte-compile-debug
- (funcall --displaying-byte-compile-warnings-fn)
- (condition-case error-info
- (funcall --displaying-byte-compile-warnings-fn)
- (error (byte-compile-report-error error-info))))))))
+ `(bytecomp--displaying-warnings (lambda () ,@body)))
+
+(defun bytecomp--displaying-warnings (body-fn)
+ (let* ((warning-series-started
+ (and (markerp warning-series)
+ (eq (marker-buffer warning-series)
+ (get-buffer byte-compile-log-buffer))))
+ (byte-compile-form-stack byte-compile-form-stack))
+ (if (or (eq warning-series 'byte-compile-warning-series)
+ warning-series-started)
+ ;; warning-series does come from compilation,
+ ;; so don't bind it, but maybe do set it.
+ (let (tem)
+ ;; Log the file name. Record position of that text.
+ (setq tem (byte-compile-log-file))
+ (unless warning-series-started
+ (setq warning-series (or tem 'byte-compile-warning-series)))
+ (if byte-compile-debug
+ (funcall body-fn)
+ (condition-case error-info
+ (funcall body-fn)
+ (error (byte-compile-report-error error-info)))))
+ ;; warning-series does not come from compilation, so bind it.
+ (let ((warning-series
+ ;; Log the file name. Record position of that text.
+ (or (byte-compile-log-file) 'byte-compile-warning-series)))
+ (if byte-compile-debug
+ (funcall body-fn)
+ (condition-case error-info
+ (funcall body-fn)
+ (error (byte-compile-report-error error-info))))))))
;;;###autoload
(defun byte-force-recompile (directory)
@@ -2202,9 +2204,10 @@ See also `emacs-lisp-byte-compile-and-load'."
;; Don't inherit lexical-binding from caller (bug#12938).
(unless (local-variable-p 'lexical-binding)
(let ((byte-compile-current-buffer (current-buffer)))
- (byte-compile-warn-x
- (position-symbol 'a (point-min))
- "file has no `lexical-binding' directive on its first line"))
+ (displaying-byte-compile-warnings
+ (byte-compile-warn-x
+ (position-symbol 'a (point-min))
+ "file has no `lexical-binding' directive on its first line")))
(setq-local lexical-binding nil))
;; Set the default directory, in case an eval-when-compile uses it.
(setq default-directory (file-name-directory filename)))