Subject: bug#76745: 31.0.50; ?d action in save-some-buffers-action-alist to view diff does not work

From: StrawberryTea <[email-masked]>
Date: Wed, 12 Mar 2025 21:58:33 -0400

Juri Linkov <[email-masked]> writes:
Well, I agree that for save-some-buffers we should enter view-mode. But
I don't see why view-mode should be disabled for diff-mode in general.
Diff-mode is a major mode that is used for viewing diffs, it is not
specifically for save-some-buffers.

The key issue here is that diff-mode serves multiple purposes:

1. Sometimes diff buffers are purely for viewing (like in
   save-some-buffers), where the primary user need is quick navigation
   and an easy way to exit

2. Other times, users need to actively work with diff content -
   navigating by sections, copying hunks, applying patches, etc.

Disabling view-mode entirely for diff-mode (as in #75993) prioritizes
the second use case at the expense of the first. But I believe a better
approach is to maintain both capabilities and let users or calling
functions decide which mode is appropriate for their context.

For viewing-only situations like save-some-buffers, view-mode provides
valuable functionality - particularly the quick navigation keys and the
critical ability to exit with 'q' which triggers exit-recursive-edit in
this context.

Rather than disabling view-mode completely for diff-mode, we should
investigate why view-mode is being activated when you do not intend it
to be. If there are specific situations where view-mode interferes with
diff-mode functionality, we should consider either disabling view-mode
in those specific contexts or exiting view-mode in those situations,
rather than making a global change that affects all diff-mode usage.
>> Hello. I have found that the fix from #75993 breaks the ?d action in
>> save-some-buffers-action-alist. The reason is that since we are not
>> entering view-mode after #75993, when we type ?q to quit the diff
>> window, we are not calling exit-recursive-edit to return to the
>> save-some-buffers queries.
>>
>> So on one hand, we want to scroll through the diff easily to decide
>> whether to save the buffer or not. But on the other hand, we want to
>> navigate by the diff sections and copy hunks. To me, this is a model
>> editing situation. The user should exit view mode to perform diff
>> commands instead of disabling view-mode for diffs altogether like in
>> #75993.
>>
>> But anyway, I propose that we revert #75993.
>
> Reverting will again steal single-letter keys from diff-mode to view-mode.
>
> Why not change only 'save-some-buffers-action-alist' and replace
>
>   (view-buffer diffbuf (lambda (_) (exit-recursive-edit)))
>
> with
>
>   (with-current-buffer diffbuf (view-mode-enter nil (lambda (_) (exit-recursive-edit))))