bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32676: [PATCH] Add option to highlight the 'next-error' error messag


From: Ernesto Alfonso
Subject: bug#32676: [PATCH] Add option to highlight the 'next-error' error message
Date: Sun, 9 Sep 2018 22:08:02 -0700

In addition to a fringe arrow, ‘next-error’ error may optionally
highlight the current error message in the ‘next-error’ buffer.
---
 doc/emacs/building.texi |  2 ++
 etc/NEWS                |  5 +++++
 lisp/simple.el          | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 496c4275bc..e0d14c14d8 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -199,6 +199,8 @@ Compilation Mode
 @kindex M-g n
 @kindex C-x `
 @findex next-error
+@findex next-error-message
+@vindex next-error-message-highlight-p
 @vindex next-error-highlight
   To visit errors sequentially, type @w{@kbd{C-x `}}
 (@code{next-error}), or equivalently @kbd{M-g M-n} or @kbd{M-g n}.
diff --git a/etc/NEWS b/etc/NEWS
index ff65a5520d..a8d3400d8f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -607,6 +607,11 @@ error.
 It can be used to set any buffer as the next one to be used by
 'next-error' and 'previous-error'.
 
++++
+*** New customizable variable 'next-error-message-highlight-p'
+In addition to a fringe arrow, ‘next-error’ error may now optionally
+highlight the current error message in the ‘next-error’ buffer.
+
 ** nxml-mode
 
 ---
diff --git a/lisp/simple.el b/lisp/simple.el
index 0ccf2f1d22..c1298965cc 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -105,6 +105,23 @@ next-error-recenter
   :group 'next-error
   :version "23.1")
 
+(defcustom next-error-message-highlight-p nil
+  "If non-nil, highlight the current error message in the ‘next-error’ buffer"
+  :type 'boolean
+  :group 'next-error
+  :version "27.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 "27.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
@@ -421,6 +438,23 @@ next-error-follow-mode-post-command-hook
          (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-p
+    (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))))))
+
+(add-hook 'next-error-hook 'next-error-message-highlight)
+
 
 ;;;
 
-- 
2.11.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]