]> git.eshelyaron.com Git - emacs.git/commitdiff
Pass unquoted filename to user-supplied MUSTMATCH predicate
authorJoseph Turner <joseph@breatheoutbreathe.in>
Wed, 31 Jan 2024 06:08:50 +0000 (22:08 -0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 11 Feb 2024 16:32:52 +0000 (17:32 +0100)
* lisp/minibuffer.el (read-file-name-default): Pass REQUIRE-MATCH
argument through substitute-in-file-name.
* lisp/minibuffer.el (read-file-name): Update docstring.

Resolves bug#68815.

(cherry picked from commit e25d11314d84cc3e606515d6551e878cec4cfee4)

lisp/minibuffer.el

index 7045c37633ee33ef3254f4637d4a4f0bacd150a5..d41c105f865111abf98efaf346b2e7b5f1292e08 100644 (file)
@@ -3817,9 +3817,10 @@ Fourth arg MUSTMATCH can take the following values:
   input, but she needs to confirm her choice if she called
   `minibuffer-complete' right before `minibuffer-complete-and-exit'
   and the input is not an existing file.
-- a function, which will be called with the input as the
-  argument.  If the function returns a non-nil value, the
-  minibuffer is exited with that argument as the value.
+- a function, which will be called with a single argument, the
+  input unquoted by `substitute-in-file-name', which see.  If the
+  function returns a non-nil value, the minibuffer is exited with
+  that argument as the value.
 - anything else behaves like t except that typing RET does not exit if it
   does non-null completion.
 
@@ -3936,7 +3937,13 @@ See `read-file-name' for the meaning of the arguments."
     (let ((ignore-case read-file-name-completion-ignore-case)
           (minibuffer-completing-file-name t)
           (pred (or predicate 'file-exists-p))
-          (add-to-history nil))
+          (add-to-history nil)
+          (require-match (if (functionp mustmatch)
+                             (lambda (input)
+                               (funcall mustmatch
+                                        ;; User-supplied MUSTMATCH expects an unquoted filename
+                                        (substitute-in-file-name input)))
+                           mustmatch)))
 
       (let* ((val
               (if (or (not (next-read-file-uses-dialog-p))
@@ -3978,7 +3985,7 @@ See `read-file-name' for the meaning of the arguments."
                                  minibuffer-completions-sort-orders))
                          (set-syntax-table minibuffer-local-filename-syntax))
                       (completing-read prompt 'read-file-name-internal
-                                       pred mustmatch insdef
+                                       pred require-match insdef
                                        'file-name-history default-filename)))
                 ;; If DEFAULT-FILENAME not supplied and DIR contains
                 ;; a file name, split it.