Subject: bug#79145: 31.0.50; doc-view-mode with auto-revert-mode emitting message when it shouldn't

From: Michael Albinus <[email-masked]>
Date: Mon, 04 Aug 2025 11:36:26 +0200

Eli Zaretskii <[email-masked]> writes:

Hi Eli,

>> >> When a buffer visits a file using doc-view-mode and auto-revert-mode
>> >> is enabled in that buffer, Emacs emits the message "Type C-c C-c to
>> >> toggle between editing or viewing the document."  every time the file
>> >> is changed.  The message is not appropriate when the major mode of
>> >> the current buffer is not doc-view-mode.
>> >>
>> >> >From emacs -Q:
>> >> 1. Visit a PDF file
>> >> 2. M-x auto-revert-mode
>> >> 3. Visit a different buffer like the scratch buffer
>> >> 4. Cause the PDF file to be changed
>> >> 5. Observe the message
>> >
>> > Tassilo, any comments or suggestions?
>>
>> Jake's observation is certainly true but it's not really doc-view
>> specific.  A similar case is shown by this recipe:
>>
>> 1. open dired for /tmp and enable dired-omit-mode and auto-revert-mode
>> 2. visit a different buffer
>> 3. touch /tmp/foo in a terminal
>> 4. observe the message "Omitting XX lines in /tmp"
>>
>> So Jake's request can be broadened to something like "buffer-bound modes
>> should suppress messages when their buffer is not visible".  I'm not
>> sure if I'd want that.  And how to implement it.  I guess we certainly
>> don't want to visit each (message...) in Emacs to check if it's
>> appropriate to show in the "buffer not visible" case...
>
> Perhaps some revert-mode specific variable that modes could bind to
> suppress these messages?  Michael, any suggestions?

In auto-revert-handler, we have the user option auto-revert-verbose. But
this is responsible only for the global "Reverting buffer `buffer'"
message.

The other messages are emitted by the respective mode-specific revert
functions. So they must be suppressed there.

In the dired case, the "Omitting ..." message could be suppressed by
let-binding dired-omit-verbose in dired-omit-expunge like

--8<---------------cut here---------------start------------->8---
(dired-omit-verbose (and dired-omit-verbose (eq (get-buffer-window) (selected-window))))
--8<---------------cut here---------------end--------------->8---

In dov-view, there must be a similar check in doc-view-minor-mode before
emitting the message accused by this bug report.

If we want to have a general mechanism, we need a new variable
auto-revert-buffer-in-progress-p which could be consulted by the several
mode-specific revert functions implementations. Or we extend the meaning
of revert-buffer-in-progress-p to the values nil, t, and `auto'. The
latter indicates, that the revert process has been started by
auto-revert.

Best regards, Michael.