emacs-devel
[Top][All Lists]
Advanced

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

Re: Eglot, project.el, and python virtual environments


From: Danny Freeman
Subject: Re: Eglot, project.el, and python virtual environments
Date: Sat, 19 Nov 2022 14:17:46 -0500

Dmitry Gutov <dgutov@yandex.ru> writes:

> Anyway, this is the problem with the popular recommendation: just add a thing 
> to
> 'project-find-functions'. It degrades performance and changes how project 
> commands work too.

Does it really change how the project commands work? That is not what I
have seen. The special project-find-functions thing only returns a
value when eglot is calling `project-current`. This only happens from
one function, `eglot--current-project`, which is called infrequently.
All other times that function returns nil so project.el falls back to
`project-try-vc`.  

Outside of eglot's one call to `project-current` the special
`project-find-functions` thing is only checking a single var for 
truthyness and returning nil. I don't see how it could adversely impact
performance. 

For reference this is the code I'm talking about:
```
(defun project-find-virtualenv-for-eglot (dir)

  (when eglot-lsp-context ;; ALWAYS NIL, except when called from 
`eglot--curent-project`

    (let ((root (locate-dominating-file dir ".virtualenv")))
      (when root
        (cons 'transient root)))))

(add-hook 'project-find-functions #'project-find-virtualenv-for-eglot)
```

-- 
Danny Freeman



reply via email to

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