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

From: Juri Linkov <[email-masked]>
Date: Tue, 30 Jun 2020 01:58:54 +0300

>> So analogously, vc.el is one of back-ends of project.el, so in vc.el
>> there should be such line for using project functions:
>>    (require 'project)
>
> Not really.
>
> project-vc (which is the project backend) resides in project.el.
>
> It calls to some VC functions, but VC itself needs no awareness of
> project.el.

I see that project.el calls some functions from preloaded vc-hooks.el
and some autoloaded functions from vc.el.

According to this design, this feature should be implemented the same way.
In 'vc-root-diff' command:

  (read-directory-name
   "Directory for VC root-diff: " nil
   (when (featurep 'project)
     (project-vc-known-roots)))

Note the same prefix 'project-vc' for vc backend of project.el.
Then 'project-vc-known-roots' in project.el be like this:

(defun project-vc-known-roots ()
  "Return a list of known vc roots."
  (seq-filter #'project-try-vc (project-known-project-roots)))

Also every command that visits a directory in vc could register their dir
in the project list when project.el is loaded, for example:

  (defun vc-dir (dir &optional backend)
   ...
   (when (featurep 'project)
    ;; Add current vc project dir to project list
    (let ((default-directory dir))
     (project-current t)))