Subject: bug#66114: [PATCH] Fix interactive prompt for selecting checkout directory

From: Joseph Turner <[email-masked]>
Date: Tue, 30 Jan 2024 00:42:21 -0800

Joseph Turner <[email-masked]> writes:

> Philip Kaludercic <[email-masked]> writes:
>
>> Joseph Turner <[email-masked]> writes:
>>
>>>                                                  However, the behavior of
>>> read-file-name is unspecified when a MUSTMATCH function returns nil:
>>>
>>> - 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.
>>>
>>> Is this a bug, a case of under-documentation, or do I misunderstand something?
>>>
>>> I'm happy to post this in a separate bug thread if you think it's worth it.
>>
>> Perhaps that would be worth doing, that way the people who know more
>> about completion than I do would be more likely to see it and help
>> out.
>
> Okay, thanks! I'll do that.

Now that #66187
(<https://yhetil.org/emacs-bugs/[email-masked]/>)
and bug#68815
(<https://yhetil.org/emacs-bugs/[email-masked]/>)
are fixed on emacs-29, I'm revisiting this issue.

With the following patch, the interactive prompt in package-vc-checkout
now offers all directory for completion (empty or not), but only exits
when the minibuffer contains an empty directory or nonexistent filename.

Testing this patch requires checking out emacs-29 after e6c82fe35e3.

Thanks!

Joseph

>From e6c82fe35e3f5de107020ee206043bd80cbfff27 Mon Sep 17 00:00:00 2001
From: Joseph Turner <[email-masked]>
Date: Tue, 30 Jan 2024 00:52:39 -0800
Subject: [PATCH] Improve package-vc-checkout interactive prompt (bug#66114)

* lisp/emacs-lisp/package-vc.el (package-vc--read-package-name): Use
read-directory-name instead of read-file-name.
---
 lisp/emacs-lisp/package-vc.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index e89ead89d4b..5c5486de290 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -825,8 +825,8 @@ package-vc-checkout
   (interactive
    (let* ((name (package-vc--read-package-name "Fetch package source: ")))
      (list (cadr (assoc name package-archive-contents #'string=))
-           (read-file-name "Clone into new or empty directory: " nil nil t nil
-                           (lambda (dir) (or (not (file-exists-p dir))
+           (read-directory-name "Clone into new or empty directory: " nil nil
+                                (lambda (dir) (or (not (file-exists-p dir))
                                              (directory-empty-p dir))))
            (and current-prefix-arg :last-release))))
   (setf directory (expand-file-name directory))
-- 
2.41.0