diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 5df1205869c..b9b5b93d1a2 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1311,10 +1311,13 @@ where the problem was detected. FILL is a prefix as in `warning-fill-prefix'. LEVEL is the level of the problem (`:warning' or `:error'). FILL and LEVEL may be nil.") +(defvar byte-compile-warning-flag nil) + (defun byte-compile-log-warning (string &optional fill level) "Log a byte-compilation warning. STRING, FILL and LEVEL are as described in `byte-compile-log-warning-function', which see." + (setq byte-compile-warning-flag t) (funcall byte-compile-log-warning-function string (or (byte-compile--warning-source-offset) @@ -2118,6 +2121,9 @@ See also `emacs-lisp-byte-compile-and-load'." (y-or-n-p (format "Save buffer %s first? " (buffer-name b)))) (with-current-buffer b (save-buffer))))) + ;; Reset the warning flag + (setq byte-compile-warning-flag nil) + ;; Force logging of the file name for each file compiled. (setq byte-compile-last-logged-file nil) (let ((byte-compile-current-file filename) @@ -2244,6 +2250,11 @@ See also `emacs-lisp-byte-compile-and-load'." target-file)))))) (unless byte-native-compiling (kill-buffer (current-buffer)))) + + ;; select the byte compile log + (if byte-compile-select-log-buffer + (if byte-compile-warning-flag (select-visible-byte-compile-log))) + (if (and byte-compile-generate-call-tree (or (eq t byte-compile-generate-call-tree) (y-or-n-p (format "Report call tree for %s? " @@ -2263,6 +2274,17 @@ See also `emacs-lisp-byte-compile-and-load'." (load target-file)) t)))) +(defcustom byte-compile-select-log-buffer nil + "If non-nil, the `byte-compile-log-buffer' window in the selected frame +is selected when there are warnings." + :type 'boolean + :group 'bytecomp) + +(defun select-visible-byte-compile-log () + "Select the visible byte compile log buffer in the selected frame" + (when-let ((window (get-buffer-window byte-compile-log-buffer))) + (select-window window))) + ;;; compiling a single function ;;;###autoload (defun compile-defun (&optional arg)