bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#41821: 28.0.50; read-directory-name in vc commands should provide de


From: Juri Linkov
Subject: bug#41821: 28.0.50; read-directory-name in vc commands should provide defaults from projects
Date: Thu, 02 Jul 2020 01:10:00 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> 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
            (lambda (orig-fun prompt &optional dir default-dirname
                              mustmatch initial)
              (when (featurep 'project)
                (setq default-dirname
                      (append (cond
                               ((null default-dirname)
                                (list (or dir default-directory)))
                               ((consp default-dirname)
                                default-dirname)
                               (t
                                (list default-dirname)))
                              (project-known-project-roots))))
              (let ((ret (funcall orig-fun prompt dir default-dirname
                                  mustmatch initial)))
                (when (featurep 'project)
                  ;; Update project list with selected project dir
                  (let ((default-directory ret))
                    (project-current t)))
                ret))
            '((name . read-directory-name-project-defaults)))

(advice-add 'vc-dir :after
            (lambda (dir &optional _backend)
              (when (featurep 'project)
                ;; Add current vc project dir to project list
                (let ((default-directory dir))
                  (project-current t))))
            '((name . vc-dir-add-project)))
#+end_src





reply via email to

[Prev in Thread] Current Thread [Next in Thread]