Subject: bug#67946: 30.0.50; [RFC PATCH] Add an option to not report "Wrote ..." when saving recentf.

From: Eli Zaretskii <[email-masked]>
Date: Thu, 21 Dec 2023 11:37:54 +0200

> From: Vladimir Nikishkin <[email-masked]>
> Date: Thu, 21 Dec 2023 11:26:52 +0800
> 
> I have the following setting in my init.el
> 
> (add-hook 'buffer-list-update-hook 'recentf-track-opened-file)
> (add-hook 'buffer-list-update 'recentf-save-list)
> 
> The first one is the one recommended by describe-function recentf-mode,
> and the second one is to make this switch persistent, and resistant to
> emacs being killed.
> 
> However, I am getting a lot of messages like
> `Wrote /home/lockywolf/.emacs.d/recentf', which are not very helpful
> normally.
> 
> I am attaching a trivial patch (001_patch-recentf-verbose.patch), which
> adds a `recentf-verbose' defcustom, which, when set to nil, would
> suppress these messages.

Thanks, I have a few comments about the proposed changes:

> +(defcustom recentf-verbose t
> +  "Non-nil means to show debugging messages related to the recentf machinery."
> +  :group 'recentf
> +  :type 'boolean)

This currently only controls the "Wrote" message, so "show debugging
messages" is a bit misleading.

Also, new defcustoms should have a :version tag

> @@ -1324,7 +1329,10 @@ recentf-save-list
>                  (format ";; coding: %s\n" recentf-save-file-coding-system)
>                  ";; End:\n")
>          (write-region (point-min) (point-max)
> -                      (expand-file-name recentf-save-file))
> +                      (expand-file-name recentf-save-file)
> +                      nil
> +                      recentf-verbose
> +                      )

You pass the value of recentf-verbose, either nil or t, to
write-region, but the only way to suppress the "Wrote" message from
write-region is to pass a non-nil, non-t value in the 5th argument;
see the doc string of write-region.  So the above will not suppress
the "Wrote" message, neither if the new defcustom is t nor if it is
nil, and the code needs some simple changes to do what you want.  Am I
missing something?

Finally, this change needs a NEWS entry.  And please accompany the
change with a ChangeLog-style commit log message; see CONTRIBUTE for
how to format the log message, and see "git log" in the repository for
examples of how we do this in practice.

Thanks again for working on this.