GNU bug report logs -
#66187
read-file-name unexpected behavior when MUSTMATCH is a function
Previous Next
Full log
View this message in rfc822 format
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> AFAIU the algorithm
> works like this: first it's checked whether a completion is allowed (by
> checking whether it's the name of an existing file and consulting
> PREDICATE when specified). Only when it is not allowed we check whether
> MUSTMATCH declares it acceptable.
Thank you!! That makes sense now.
> This is not really explained in the docstring, however.
>
> In your example, the default-directory is the name of an existing file,
> so the MUSTMATCH argument is irrelevant, the specified PREDICATE is
> fulfilled, so it's accepted as input.
>
> If I guess correctly I think you want something like this:
>
> #+begin_src emacs-lisp
> (let ((acceptable-p (lambda (filename)
> (and (file-directory-p filename)
> (directory-empty-p filename)))))
> (read-file-name "Clone into new or empty directory: " nil nil
> (lambda (filename)
> (if (file-exists-p filename)
> (funcall acceptable-p filename)
> t))
> nil
> acceptable-p))
> #+end_src
>
> Does that come close?
Thank you! What I was hoping for may not have a clean solution:
- the completions buffer displays and allows tab-completion for all
directories, empty or not, then
- upon pressing RET on a non-empty directory, the "[Match required]"
message appears. Only upon pressing RET on an empty directory does
completion succeed.
If this cannot be accomplished elegantly, I'll consider other designs
for the interactive prompt in package-vc-checkout.
Thanks!!
Joseph
This bug report was last modified 1 year and 173 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.