unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers
@ 2022-09-01 22:40 Dima Kogan
  2022-09-02  6:10 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Dima Kogan @ 2022-09-01 22:40 UTC (permalink / raw)
  To: 57534

Hi. I'm seeing this:

1. seq 10 > /tmp/file

2. emacs -Q /tmp/file

3. (highlight-lines-matching-regexp "3")

   This is bound to "M-s h l". I see the line containing "3" highlighted
   in yellow, as expected

4. M-x auto-revert-mode

5. Back in the shell: seq 20 > /tmp/file


auto-revert-mode kicks in, updating the buffer with the results of 'seq
20' (possibly updating to an empty buffer first, if we react immediately
to the file truncation). At this point I would expect either:

1. The buffer being fully reverted, with all the highlighting
   disappearing. This is what happens if we did M-x revert buffer

2. The buffer contents being reverted, but the highlighting being
   reapplied

In this auto-revert scenario, we get something in-between: after the
auto-revert hi-lock-interactive-patterns still contains the highlighting
regex, but no highlighting actually happens. It'd be really nice and
useful if the highlighting stayed.

Thanks!





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers
  2022-09-01 22:40 bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers Dima Kogan
@ 2022-09-02  6:10 ` Eli Zaretskii
  2022-09-02  7:04   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-09-02  6:10 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 57534

> From: Dima Kogan <dima@secretsauce.net>
> Date: Thu, 01 Sep 2022 15:40:01 -0700
> 
> Hi. I'm seeing this:
> 
> 1. seq 10 > /tmp/file
> 
> 2. emacs -Q /tmp/file

This "file" is in Fundamental mode, yes?  If not, which major mode is
used, and does that major mode turns on Font Lock?

> 3. (highlight-lines-matching-regexp "3")
> 
>    This is bound to "M-s h l". I see the line containing "3" highlighted
>    in yellow, as expected
> 
> 4. M-x auto-revert-mode
> 
> 5. Back in the shell: seq 20 > /tmp/file
> 
> 
> auto-revert-mode kicks in, updating the buffer with the results of 'seq
> 20' (possibly updating to an empty buffer first, if we react immediately
> to the file truncation). At this point I would expect either:
> 
> 1. The buffer being fully reverted, with all the highlighting
>    disappearing. This is what happens if we did M-x revert buffer
> 
> 2. The buffer contents being reverted, but the highlighting being
>    reapplied
> 
> In this auto-revert scenario, we get something in-between: after the
> auto-revert hi-lock-interactive-patterns still contains the highlighting
> regex, but no highlighting actually happens. It'd be really nice and
> useful if the highlighting stayed.

The documentation of hi-lock-mode says:

  In buffers where Font Lock mode is enabled, patterns are
  highlighted using font lock.  In buffers where Font Lock mode is
  disabled, patterns are applied using overlays; in this case, the
  highlighting will not be updated as you type.  The Font Lock mode
  is considered \"enabled\" in a buffer if its `major-mode'
  causes `font-lock-specified-p' to return non-nil, which means
  the major mode specifies support for Font Lock.

If I use your recipe in a file visited with C Mode, which does use
Font Lock, the auto-revert doesn't lose the highlighted lines.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers
  2022-09-02  6:10 ` Eli Zaretskii
@ 2022-09-02  7:04   ` Juri Linkov
  2022-09-02  7:22     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2022-09-02  7:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dima Kogan, 57534

>> 3. (highlight-lines-matching-regexp "3")
>>
>>    This is bound to "M-s h l". I see the line containing "3" highlighted
>>    in yellow, as expected
>>
>> 4. M-x auto-revert-mode
>
> If I use your recipe in a file visited with C Mode, which does use
> Font Lock, the auto-revert doesn't lose the highlighted lines.

However, after manual revert with 'C-x x g' highlighting is still lost.
But this is bug#50431 where 'C-x x g' should be fixed to restore minor modes.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers
  2022-09-02  7:04   ` Juri Linkov
@ 2022-09-02  7:22     ` Eli Zaretskii
  2022-09-02 14:27       ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-09-02  7:22 UTC (permalink / raw)
  To: Juri Linkov; +Cc: dima, 57534

> From: Juri Linkov <juri@linkov.net>
> Cc: Dima Kogan <dima@secretsauce.net>,  57534@debbugs.gnu.org
> Date: Fri, 02 Sep 2022 10:04:25 +0300
> 
> >> 3. (highlight-lines-matching-regexp "3")
> >>
> >>    This is bound to "M-s h l". I see the line containing "3" highlighted
> >>    in yellow, as expected
> >>
> >> 4. M-x auto-revert-mode
> >
> > If I use your recipe in a file visited with C Mode, which does use
> > Font Lock, the auto-revert doesn't lose the highlighted lines.
> 
> However, after manual revert with 'C-x x g' highlighting is still lost.

That's not the same revert as in auto-revert-mode.

> But this is bug#50431 where 'C-x x g' should be fixed to restore minor modes.

I'm not sure this is one of the minor modes to be restored.  Maybe
optionally, but not unconditionally.  See the discussion in that bug.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers
  2022-09-02  7:22     ` Eli Zaretskii
@ 2022-09-02 14:27       ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2022-09-02 14:27 UTC (permalink / raw)
  To: Eli Zaretskii, Juri Linkov; +Cc: dima@secretsauce.net, 57534@debbugs.gnu.org

> > But this is bug#50431 where 'C-x x g' should be fixed
> > to restore minor modes.
> 
> I'm not sure this is one of the minor modes to be restored.  Maybe
> optionally, but not unconditionally.  See the discussion in that bug.

+2.

Reverting is not about restoring minor modes.
Certainly not blindly so.  Not at all.

Reverting is specific to the major mode.

The major mode gets to decide what reverting
means/does.  The major mode can decide to
restore whatever it likes, including this or
that minor mode.  Nothing should "restore the
minor modes" by default.

My crystal ball whispers that calls for
reverting to "restore minor modes" are trying
to use a sledge hammer where at most a pair
of tweezers might be needed in some uncommon
scenario.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-02 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 22:40 bug#57534: 29.0.50; Highlighting lost after auto-revert-mode triggers Dima Kogan
2022-09-02  6:10 ` Eli Zaretskii
2022-09-02  7:04   ` Juri Linkov
2022-09-02  7:22     ` Eli Zaretskii
2022-09-02 14:27       ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).