From a37d801a48d4fba0c783ec899a94f50b979418a4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 4 Apr 2024 13:00:12 -0400 Subject: [PATCH] fix(lib): find-subling-file-search: wrong-number-of-args error I backported `find-sibling-file` from Emacs 29+ in 198fe82, but it passes a third argument (REGEXP) to `file-expand-wildcards` which wasn't introduced until 29, so users on 28 or earlier would see a wrong-number-of-arguments error (see #7795). Rather than backport the entire `file-expand-wildcards` function (risking other edge cases), I've advised its usage in `find-sibling-file-search` to behave as it would in 29+ with a non-nil REGEXP argument. Amend: 198fe82b6d49 Fix: #7795 --- lisp/lib/files.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 022be0003..94b47d4a3 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -594,7 +594,12 @@ see), and if nil, defaults to `find-sibling-rules'." (nconc results (mapcar #'expand-file-name - (file-expand-wildcards expansion nil t))))))))) + ;; `file-expand-wildcards' has a new REGEXP + ;; argument in 29+ that is needed here. This swap + ;; makes it behave as if REGEXP == t. + (letf! (defun wildcard-to-regexp (wildcard) + (concat "\\`" wildcard "\\'")) + (file-expand-wildcards expansion nil)))))))))) ;; Delete the file itself (in case it matched), and remove ;; duplicates, in case we have several expansions and some match ;; the same subsets of files.