Subject: bug#38778: 26.3; next-error-highlight set to t doesn't seem semi-permanent

From: Juri Linkov <[email-masked]>
Date: Tue, 03 Mar 2020 00:03:10 +0200

> I tried this with emacs -Q on a mac using Gnu Emacs 26.3.
>
> Using customize-variable I set next-error-highlight to t ("Semipermanent
> highlighting") and saved that value for the current session.
>
> I then ran M-x grep and got a *grep* buffer and moved through the errors
> using n and p. The matches appeared in another window and were
> highlighted but the highlighting disappeared after a short time (could
> be the default value of 0.5 seconds) even if I didn't hit a key.
>
> My understanding of next-error-highlight is when set to t, the
> highlighting should remain until I enter another command. Yet 
> it seems to disappear on it's own.

Sorry for the delay, I looked at this bug report, and the solution for you
is to customize next-error-highlight-no-select instead of next-error-highlight,
because next-error-highlight-no-select affects the highlighting of
non-selected windows displayed from the *grep* buffer with n and p keys.

Before closing this bug report, I propose to improve the documentation:

diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 272b08d08e..95bdca737d 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -214,6 +214,7 @@ Compilation Mode
 @kindex C-x `
 @findex next-error
 @vindex next-error-highlight
+@vindex next-error-highlight-no-select
   To visit errors sequentially, type @w{@kbd{C-x `}}
 (@code{next-error}), or equivalently @kbd{M-g M-n} or @kbd{M-g n}.
 This command can be invoked from any buffer, not just a Compilation
@@ -258,7 +259,9 @@ Compilation Mode
 
   When Emacs visits the locus of an error message, it momentarily
 highlights the relevant source line.  The duration of this highlight
-is determined by the variable @code{next-error-highlight}.
+is determined by the variable @code{next-error-highlight} for
+loci in selected buffers, and @code{next-error-highlight-no-select} for
+loci in non-selected buffers.
 
 @vindex compilation-context-lines
   If the @file{*compilation*} buffer is shown in a window with a left
diff --git a/lisp/simple.el b/lisp/simple.el
index 688dbcc947..d1e10850bf 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -76,6 +76,8 @@ next-error
 
 (defcustom next-error-highlight 0.5
   "Highlighting of locations in selected source buffers.
+See `next-error-highlight-no-select' to customize highlighting
+of locations in non-selected buffers.
 If a number, highlight the locus in `next-error' face for the given time
 in seconds, or until the next command is executed.
 If t, highlight the locus until the next command is executed, or until
@@ -91,7 +93,9 @@ next-error-highlight
   :version "22.1")
 
 (defcustom next-error-highlight-no-select 0.5
-  "Highlighting of locations in `next-error-no-select'.
+  "Highlighting of locations in non-selected source buffers.
+Usually non-selected buffers are displayed by `next-error-no-select'.
+See `next-error-highlight' to customize highlighting of selected buffers.
 If number, highlight the locus in `next-error' face for given time in seconds.
 If t, highlight the locus indefinitely until some other locus replaces it.
 If nil, don't highlight the locus in the source buffer.