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

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

bug#57418: 28.1; Projects not saved when vc-handled-backends is nil


From: Dmitry Gutov
Subject: bug#57418: 28.1; Projects not saved when vc-handled-backends is nil
Date: Fri, 26 Aug 2022 17:21:13 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 26.08.2022 10:46, Philip Kaludercic wrote:
Louis-Guillaume Gagnon<gagnonlg@protonmail.com>  writes:

Good day,

I've recently been migrating from projectile to the built-in
project.el. Since then, one major annoyance is that the projects are
never saved into project-list-file, so I have to re-enter the projects'
paths everytime I make a query.

I have narrowed it down to vc-handled-backends being set to nil in my
init-file. If it's left at its default, it works as expected. I could
just leave the variable at its default but (iirc) it's part of a bunch
of optimizations I made to speedup my TRAMP setup, so I'm reluctant to
do that.  And just to be perfectly clear, the rest of project mode seemingly
works as expected if that variable is nil, it's just the projects are
not saved.

Steps to reproduce from emacs -Q:

+ (setq 'vc-handled-backends nil)

+ Use project.el to find a file in any project not in your
project-list-file, e.g. with C-x p p

+ Open your project-list-file, "/.emacs.d/projects" in my case

Expected result: The recently opened project is listed
Actual result: The recently opened project is*not*  listed
This is to be expected, as by default `project-find-functions' only
includes one function that uses and relies on VC.  If it were just this,
I would therefore not consider this to be a bug.  Does anything else
work?  `project-find-file', `project-shell', `project-compile', ...?

I'm honestly surprised that things work with vc-handled-backends disabled.

Louis-Guillaume, does (project-current) ever evaluate to non-nil on your system? I'm guessing you end up picking the project directory manually every time.

What might be worth doing is issuing a warning if `project-try-vc' (the
default project-finding-function) is invoked while VC is effectively
disabled.

Probably not: after all, the user can have some next backend configured. And we allow setting vc-handled-backends to nil.

You could try solving this by either adding your own alternative to
`project-try-vc' (e.g. if you just use Git, then this

--8<---------------cut here---------------start------------->8---
(defun project-try-git (dir)
   "Find a super-directory of DIR containing a root file."
   (let ((repo (locate-dominating-file dir ".git")))
     (and repo (list 'git dir))))

(cl-defmethod project-root ((project (head git)))
   "Return the root of a explicit PROJECT."
   (cadr project ))

(with-eval-after-load 'project
   (add-hook 'project-find-functions #'project-try-git))
--8<---------------cut here---------------end--------------->8---

might be enough, but still be optimised a bit more).

This should work, yes.

We could also add a variable which would substitute vc-handled-backends for the purposes of project.el (we'd temporarily use its value). Not sure it's worth the added complexity, though.

Another idea might be to just disable VC for Tramp, or rather just some
Tramp connections?

(setq-local vc-handled-backends) inside find-file-hook behind a file-remote-p check could do the trick.





reply via email to

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