Subject: Re: bug#78666: 31.0.50; recentf-open-files reports opening the last file accessed

From: Stephen Berman <[email-masked]>
Date: Sat, 21 Jun 2025 18:40:21 +0200

On Sat, 21 Jun 2025 12:22:07 +0300 Eli Zaretskii <[email-masked]> wrote:

>> Cc: [email-masked]
>> Date: Tue, 17 Jun 2025 09:51:03 +0200
>> From:  Stephen Berman via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>> 
>> On Wed, 4 Jun 2025 09:43:46 -0500 Rick <[email-masked]> wrote:
>> 
>> >> I took a closer look at recentf.el and found that the messages (which
>> >> come from the :help-echo property in `recentf-open-files-item') are
>> >> displayed only on invoking `recentf-open-files' and on tabbing between
>> >> items in the *Open Recent* buffer; invoking `recentf-edit-list' or
>> >> tabbing between check boxes in that list does not display such a message
>> >> (so my assertion above was wrong in referring to check boxes).  So you
>> >> don't need to change `recentf-edit-list'.  (And in fact, it isn't
>> >> necessary to change `recentf-open-files' either, see the attached
>> >> patch.)
>> >>
>> >> Also, your change only affects displaying the message on creating the
>> >> open file dialog; further messages are still displayed when tabbing
>> >> between items in that buffer.  In your second post you said you saw
>> >> several messages, also repeated ones.  AFAICT all messages but the first
>> >> can only result from tabbing between items; if this is not what you see,
>> >> please give a precise recipe detailing what you find problematic.
>> >>
>> >> If you do also want to suppress the messages on tabbing between items,
>> >> then I think more extensive changes are needed.  For one thing, since
>> >> displaying the messages has long been the status quo, suppressing them
>> >> should be optional (though I agree with you that displaying the message
>> >> on creating the *Open Recent* buffer seems like a bug).  Moreover, since
>> >> tabbing invokes the commands `widget-forward' and `widget-backward'
>> >> (which in turn invoke `widget-move'), these need to be changed as well.
>> >> The attached patch implements these changes.
>> >>
>> >> Steve Berman
>> >
>> > Nice bonus.  Thanks
>> 
>> Since my patch goes beyond a minimal fix for the problem reported, I
>> think it's appropriate that at least one of the Emacs maintainers should
>> approve it or explain why it should not be installed.  So this is a
>> request for maintainer feedback.  Thanks.
>
> I don't use recentf, so I have hard time understanding what this is
> about.  What are those messages which you are talking about, and why
> and under what circumstances would users want to suppress them?

The messages are mostly of the form "Open <file name>" (if the files
listed in the *Open Recent* buffer are displayed as a tree structure,
there are also the messages "Collapse node" and "Expand node").  These
messages inform the user what action clicking (or typing RET) on an
entry in the list executes (the entries are all widgets: the file names
are links, and with a tree structure, there are also
expandable/collapsible nodes that contain file names as leaves).  Since
the meaning of the message is pretty obvious, and a message appears
(with a different file name) each time the user tabs between entries in
the list, it seems reasonable that many users would prefer not to see
the messages in the echo area (and also have them in *Messages*).

Indeed, since the messages are also displayed in tooltips, it might have
been preferable if displaying them in the echo area and in *Messages*
had been suppressed by default.  However, the messages are shown on
invoking `widget-move' and the ability to suppress them by passing an
optional argument to that function was added in commit fd86149b1a05 many
years after recentf.el first appeared in Emacs.  That is why I proposed
making suppressing the messages configurable, defaulting to showing the
messages, since that's the way it's always been in recentf.el.

The patch does unconditionally suppress the message in one case: on
invoking `recentf-open-files', which was what prompted the OP to file
the bug report.  This command automatically and noninteractively moves
point to the first file entry in the *Open Recent* buffer using
`widget-move', which displays the message.  And it is displayed even if
the buffer is not visible (e.g., if `recentf-open-files' is invoked
noninteractively from another function that then changes the current
buffer), so in this case showing the message is clearly inappropriate.
However, if `recentf-open-files' is invoked interactively, so *Open
Recent* is the current buffer, then I suppose showing the message
initially makes as much sense as showing it on tabbing.  If so, I could
adjust the patch accordingly.

On the other hand, given the small information value of the messages,
breaking the existing behavior by defaulting to suppressing the
messages, or, even more radically, by unconditionally suppressing the
messages, does not seem too unreasonable, especially since they can
still be viewed in tooltips.  What do you think?

Steve Berman