Subject: Re: bug#41821: 28.0.50; read-directory-name in vc commands should provide defaults from projects

From: Dmitry Gutov <[email-masked]>
Date: Thu, 2 Jul 2020 17:39:25 +0300

On 02.07.2020 01:10, Juri Linkov wrote:
>> we at least put this feature request on hold (and, for now,
>> revert the installed patches).
> 
> Ok, reverted the installed patches.
> 
> It's easy to achieve the same in the init file with these
> simple advises.  Now this works perfectly from POV of users
> who prefer to use project directories everywhere in all prompts
> that ask for a directory:
> 
> #+begin_src emacs-lisp
> ;; When a prompt of some commands such as 'rgrep' or 'vc-print-log' asks for
> ;; a directory name, allow 'M-n' to access the most recently used project
> ;; directories saved in ~/.emacs.d/projects:
> 
> (advice-add 'read-directory-name :around

I figured you might want to define a vc-specific wrapper function for 
read-directory-name, for ease of advising. But now I'm not so sure.

>                  (when (featurep 'project)
>                    ;; Update project list with selected project dir
>                    (let ((default-directory ret))
>                      (project-current t)))

The 't' argument is counter-productive here. You don't want it to 
prompt, which will happen when the target directory is in the end 
outside of any detected projects.

And really if you just do this in an ad-hoc advice (and recommend it to 
other users), it's probably better to just remove this call for 
simplicity. After all, you probably interact with "proper" project 
commands anyway. And they will put the current project at the top of the 
history.