From: Ernesto Alfonso Date: Wed, 14 Oct 2020 05:45:21 +0000 (+0200) Subject: Add option to highlight the 'next-error' error message X-Git-Tag: emacs-28.0.90~5640 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1ee5a4cb1afe5a55d78e35cab2ad8651196c8967;p=emacs.git Add option to highlight the 'next-error' error message * lisp/simple.el (next-error-message-highlight): (next-error-message): New faces (bug#32676). (next-error--message-highlight-overlay): New internal variable. (next-error-message-highlight): New function. (next-error-found): Call the function. --- diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index 5f7d9b7ab8c..573b7ad71a2 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi @@ -213,6 +213,8 @@ Select a buffer to be used by next invocation of @code{next-error} and @kindex M-g n @kindex C-x ` @findex next-error +@findex next-error-message +@vindex next-error-message-highlight @vindex next-error-highlight @vindex next-error-highlight-no-select To visit errors sequentially, type @w{@kbd{C-x `}} diff --git a/etc/NEWS b/etc/NEWS index 334d782a1f6..0ee69d9af9f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1134,6 +1134,11 @@ window after starting). This variable defaults to nil. ** Miscellaneous ++++ +*** New user option 'next-error-message-highlight'. +In addition to a fringe arrow, 'next-error' error may now optionally +highlight the current error message in the 'next-error' buffer. + +++ *** New user option 'tab-first-completion'. If 'tab-always-indent' is 'complete', this new option can be used to diff --git a/lisp/simple.el b/lisp/simple.el index b6d4e0603ee..a24f2844aa3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -118,6 +118,23 @@ If non-nil, the value is passed directly to `recenter'." :group 'next-error :version "23.1") +(defcustom next-error-message-highlight nil + "If non-nil, highlight the current error message in the `next-error' buffer." + :type 'boolean + :group 'next-error + :version "28.1") + +(defface next-error-message + '((t (:inherit highlight))) + "Face used to highlight the current error message in the `next-error' buffer." + :group 'next-error + :version "28.1") + +(defvar next-error--message-highlight-overlay + nil + "Overlay highlighting the current error message in the `next-error' buffer.") +(make-variable-buffer-local 'next-error--message-highlight-overlay) + (defcustom next-error-hook nil "List of hook functions run by `next-error' after visiting source file." :type 'hook @@ -376,6 +393,7 @@ and TO-BUFFER is a target buffer." (when next-error-recenter (recenter next-error-recenter)) (funcall next-error-found-function from-buffer to-buffer) + (next-error-message-highlight) (run-hooks 'next-error-hook)) (defun next-error-select-buffer (buffer) @@ -460,6 +478,21 @@ buffer causes automatic display of the corresponding source code location." (next-error-no-select 0)) (error t)))) +(defun next-error-message-highlight () + "Highlight the current error message in the ‘next-error’ buffer." + (when next-error-message-highlight + (with-current-buffer next-error-last-buffer + (when next-error--message-highlight-overlay + (delete-overlay next-error--message-highlight-overlay)) + (save-excursion + (goto-char compilation-current-error) + (let ((ol (make-overlay (line-beginning-position) (line-end-position)))) + ;; do not override region highlighting + (overlay-put ol 'priority -50) + (overlay-put ol 'face 'next-error-message) + (overlay-put ol 'window (get-buffer-window)) + (setf next-error--message-highlight-overlay ol)))))) + ;;;