]> git.eshelyaron.com Git - emacs.git/commitdiff
Add option to highlight the 'next-error' error message
authorErnesto Alfonso <erjoalgo@gmail.com>
Wed, 14 Oct 2020 05:45:21 +0000 (07:45 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 14 Oct 2020 05:45:21 +0000 (07:45 +0200)
* 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.

doc/emacs/building.texi
etc/NEWS
lisp/simple.el

index 5f7d9b7ab8c64f36b749914660057fdfc05d1c53..573b7ad71a2b07d13168fffd79602748383a74b8 100644 (file)
@@ -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 `}}
index 334d782a1f61f09f7f75033277cee0abcb15e6bc..0ee69d9af9f9e11d2fe524974b7a9e68bf90f492 100644 (file)
--- 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
index b6d4e0603eea14c3288d043172df419b58b795a0..a24f2844aa3e92079e77e8f30ec64356613bb2dd 100644 (file)
@@ -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))))))
+
 \f
 ;;;