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

From: Rick <[email-masked]>
Date: Tue, 3 Jun 2025 19:21:19 -0500

It seems you are confirming that the messages are in fact spurious
at this point in the execution process because they are generated
prior to the window being presented to the user.   You are
describing messages that are only useful once the user starts
being able to interact with the buffer so other than at this point
they are correct, necessary, appropriate.

Given I'm not mistaken, I'm now much more confident that the
fix I suggested an hour or so ago ago is only pretty close to
the correct way to deal with it.  I will now amend my suggestion
to the following.

Add the optional parameter (accepted by widget-move) to
recentf-dialog-goto-first so that 't' can be passed to widget-move
when recentf-edit-list and recentf-open-files call it.  All other
callers will default to nil and therefore be unaffected.  This should
cleanly remove them exactly and only where they are inappropriate.

(defun recentf-dialog-goto-first (widget-type *_&optional quietly_*)
   "Move the cursor to the first WIDGET-TYPE in current dialog.
Go to the beginning of buffer if not found."
   (goto-char (point-min))
   (condition-case nil
       (let (done)
         (widget-move 1 _*quietly*_)
         (while (not done)
           (if (eq widget-type (widget-type (widget-at (point))))
               (setq done t)
             (widget-move 1 _*quietly*_))))
     (error
      (goto-char (point-min)))))

(defun recentf-open-files (&optional files buffer-name)
...
     (recentf-dialog-goto-first 'link *_t_*)))

(defun recentf-edit-list ()
...
     (recentf-dialog-goto-first 'checkbox *_t_*)))

On 6/3/25 17:51, Stephen Berman wrote:
> On Sun, 1 Jun 2025 18:34:45 -0500 Rick<[email-masked]> wrote:
>
>> --text follows this line--
>> You can recreate most of the problem starting with -Q however you must
>> have a previously populated recentf file before starting.
>>
>> M-x recentf-mode
>> M-x recentf-open-files
>>
>> Now switch to the *Messagers* buffer and notice something similar to:
>>
>>      Loading /home/rick/.emacs.d/recentf...done     Cleaning up the recentf
>> list...done (0 removed)     Mark set     Open
>> /snap/emacs/2827/usr/share/emacs/31.0.50/lisp/files.el.gz
>>
>> Observe that it claims to have opened the most recent item on recentf-list,
>> as loaded from the pre-populated recentf file.  In my case .../files.el.gz.
>>
>> There doesn't seem to be a buffer actually associated with the file but
>> it's unclear whether it was subsequently closed or a spurious message.
> I think you misunderstood those messages: each one is help text to
> inform you that by checking the box of that item you will open the file
> (in GUI Emacs you can see the same text in a tooltip if you move the
> mouse pointer over the item).  So they are not informing you that the
> file has been opened.
>
> Steve Berman