GNU bug report logs - #68815
Unexpected behavior with read-file-name and functional REQUIRE-MATCH argument

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> breatheoutbreathe.in>

Date: Tue, 30 Jan 2024 09:32:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Subject: bug#68815: closed (Re: bug#68815: Unexpected behavior with
 read-file-name and functional REQUIRE-MATCH argument)
Date: Tue, 06 Feb 2024 21:10:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#68815: Unexpected behavior with read-file-name and functional REQUIRE-MATCH argument

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 68815 <at> debbugs.gnu.org.

-- 
68815: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68815
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: michael_heerdegen <at> web.de, Philip Kaludercic <philipk <at> posteo.net>,
 Eli Zaretskii <eliz <at> gnu.org>, 68815-done <at> debbugs.gnu.org,
 stefankangas <at> gmail.com
Subject: Re: bug#68815: Unexpected behavior with read-file-name and
 functional REQUIRE-MATCH argument
Date: Tue, 06 Feb 2024 16:08:47 -0500
> Please see the attached patch.

Thanks, Joseph, pushed to `emacs-29`,


        Stefan


[Message part 3 (message/rfc822, inline)]
From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: Emacs Bugs Mailing List <bug-gnu-emacs <at> gnu.org>
Subject: Unexpected behavior with read-file-name and functional
 REQUIRE-MATCH argument
Date: Tue, 30 Jan 2024 01:00:47 -0800
Hello!

With #66187 resolved (<https://yhetil.org/emacs-bugs/87cytlqmqh.fsf <at> breatheoutbreathe.in/>),
I reexamined #66114 (<https://yhetil.org/emacs-bugs/87v8bzi7iz.fsf <at> breatheoutbreathe.in/>),
only to discover that filename completion with a functional
REQUIRE-MATCH argument doesn't work as expected.

To reproduce:

emacs -Q on the tip of the emacs-29 branch (after commit 77f5d4d523a), run...

(let ((default-directory "~/"))
  (read-directory-name "Clone into new or empty directory: " nil nil
                       (lambda (dir) (or (not (file-exists-p dir))
                                    (directory-empty-p dir)))))

...then type "/tmp/" (the whole minibuffer now reads "~//tmp") then RET.

Expected: Completion does not exit, instead saying "[No match]".

Actual: Completion exits, returning "/tmp/".

If I delete the leading "~/" before typing "/tmp/", I get the expected result.

The issue appears to be inside completion--complete-and-exit:

((functionp minibuffer-completion-confirm)
    (if (funcall minibuffer-completion-confirm
                 (buffer-substring beg end))  ; Here, buffer-substring returns "~//tmp/"
        (funcall exit-function)
      (unless completion-fail-discreetly
	(ding)
	(completion--message "No match"))))

Since (file-exists-p "~//tmp/") returns nil, the whole predicate returns
t and the minibuffer completes "/tmp/".

In completion--complete-and-exit, should (buffer-substring beg end)
return only "/tmp/"?

Or maybe (file-exists-p "~//tmp/") should return t?

Thank you!!

Joseph



This bug report was last modified 1 year and 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.