New user option and function 'recentf-exclude-ignored-extensions'

* lisp/recentf.el (recentf-exclude-ignored-extensions): New
user option.
(recentf-exclude-ignored-extensions): New function.
* etc/NEWS: Announce the new option and function.

(Bug#80347)
This commit is contained in:
Stéphane Marks 2026-03-02 14:24:53 -05:00 committed by Philip Kaludercic
parent a7517d6ef8
commit 81d2a7a2f5
No known key found for this signature in database
2 changed files with 28 additions and 0 deletions

View file

@ -1797,6 +1797,13 @@ messages. To suppress these messages, customize the user option
'recentf-suppress-open-file-help' to non-nil. The default value of this
option is nil.
---
*** New user option and function 'recentf-exclude-ignored-extensions'.
Add the new function 'recentf-exclude-ignored-extensions' to the list
'recentf-exclude' to ignore files whose extensions are listed in the
user option of the same name 'recentf-exclude-ignored-extensions'. If
that option is nil, 'completion-ignored-extensions' is used.
** Saveplace
---

View file

@ -115,6 +115,27 @@ must return non-nil to exclude it."
:group 'recentf
:type '(repeat (choice regexp function)))
(defcustom recentf-exclude-ignored-extensions nil
"Optionally ignore file names ending in any string in this list.
To use this, add the function `recentf-exclude-ignored-extensions' to
the list `recentf-exclude'.
If this option is nil, use the values from the variable
`completion-ignored-extensions', which see."
:group 'recentf
:version "31.1"
:type '(repeat string))
(defun recentf-exclude-ignored-extensions (file-name)
"Return non-nil if FILE-NAME has an ignored extension.
The user option `completion-ignored-extensions' determines whether or
not a file extension counts as ignored. You can add this function to
`recentf-exclude'."
(and-let* ((extension (file-name-extension file-name)))
(string-match-p
(regexp-opt (or recentf-exclude-ignored-extensions
completion-ignored-extensions))
(concat "\\." (regexp-quote extension) "\\'"))))
(defun recentf-access-file (filename)
"Check whether FILENAME is accessible."
(ignore-errors (not (access-file filename "Checking recentf file"))))