Subject: bug#67946: [PATCH v3] lisp/recentf.el: Add verbosity option

From: Stefan Kangas <[email-masked]>
Date: Wed, 12 Feb 2025 21:19:38 -0800

Lockywolf <[email-masked]> writes:

>> Ping.  Vladimir, could you look into Eli's comments above and re-send
>> the patch?
>
> Sorry, it has been a long time.

No problem, and thanks for sending an updated patch.

> From 43a55892d510fd27b4d6d734f8eae80b241e9198 Mon Sep 17 00:00:00 2001
> From: Lockywolf <[email-masked]>
> Date: Thu, 13 Feb 2025 11:51:50 +0800
> Subject: [PATCH] lisp/recentf.el: Add verbosity option
>
> * lisp/recentf.el: add verbosity (bug#67946)
>   recentf-verbosity: add defcustom to control verbosity
>   (recentf-save-list): make use of recentf-verbosity
> ---
>  etc/NEWS        |  7 +++++++
>  lisp/recentf.el | 15 ++++++++++++++-
>  2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/etc/NEWS b/etc/NEWS
> index 33f5df84d4b..b7de9384fe7 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -500,6 +500,13 @@ This user option controls the width of the type column on the bookmark
>  menu 'bookmark-bmenu-list'.  The default value is 8 which is backwards
>  compatible.
>
> +** Recentf
> +
> +---
> +*** New user option 'recentf-verbose'.
> +By default 'recentf-save-list' prints a message when saving the
> +recentf list.  The new option, if set to nil, suppresses this message.
> +
>  ** Saveplace
>
>  ---
> diff --git a/lisp/recentf.el b/lisp/recentf.el
> index a282fbee3b1..eeeade8a5f1 100644
> --- a/lisp/recentf.el
> +++ b/lisp/recentf.el
> @@ -320,6 +320,14 @@ recentf-show-file-shortcuts-flag
>  used as shortcuts to open the Nth file."
>    :group 'recentf
>    :type 'boolean)
> +
> +(defcustom recentf-verbosity 1
> +  "Whether to show verbose messages about low-level recentf actions.
> +0 means to not show debugging messages related to the recentf machinery.
> +1 means show messages that were printed by default on Emacs <= 31.1."
> +  :group 'recentf
> +  :type 'integer
> +  :version "31.1")

I think this should be a boolean called `recentf-verbose` or even
`recentf-messages`.  If there is a strong need for more fine-grained
control, we can always introduce an integer option later.

I would also set it to nil by default, because as we discussed earlier
these messages are unlikely to be useful.  We should of course then also
explain in NEWS how to get the old behavior back.

>
>  
>  ;;; Utilities
>  ;;
> @@ -1331,7 +1339,12 @@ 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
> +                      (if (>= recentf-verbosity 1)
> +                          nil ;; show "Wrote ..." messages.
> +                        1) ;; non-nil, non-t, non-string, do not show.
> +                      )

I think the comments here are superfluous; the `write-region` interface
should be well-known to anyone looking at this code.  That last part
could probably just be (with the boolean option):

    (and recentf-verbose 1)

>
>          (when recentf-save-file-modes (set-file-modes
> recentf-save-file recentf-save-file-modes)) nil) -- 2.46.3
>
>
>
> --
> Your sincerely,
> Vladimir Nikishkin (MiEr, lockywolf)
> (Laptop)