Subject: Re: bug#42136: 26.1.90; rgrep uses a directory that was not actually given

From: Benjamin Riefenstahl <[email-masked]>
Date: Fri, 03 Jul 2020 16:10:54 +0200

Hi Juri,

Juri Linkov writes:
> (advice-add 'read-directory-name :around
>             (lambda (orig-fun prompt &optional dir default-dirname
> 			      mustmatch initial)
>               (cond
> 	       ((equal prompt "Base directory: ")
> 		(funcall orig-fun prompt dir default-dirname
> 			 nil initial))
>                (t
> 		(funcall orig-fun prompt dir default-dirname
> 			 mustmatch initial))))
>             '((name . read-directory-name-no-mustmatch)))
>
> It overrides the MUSTMATCH argument of read-directory-name in rgrep.

Thanks for the suggestion.  Sadly this seems to make things worse:

* emacs -Q (in ~)
* Eval your advice. 
* M-x make-directory RET /tmp/test RET
* M-x rgrep RET [...] /tmp/te RET
* Result: No confirmation, the search runs in "~" (!)

I tried read-directory-name with all variations of MUSTMATCH, and I
believe none of them helps me here.  I guess I want an additional mode,
like 'confirm-automatic-completion, which handles TAB as before, but
with RET it would require confirmation before changing the result.

benny