emacs-devel
[Top][All Lists]
Advanced

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

Re: Project local variables.


From: Dmitry Gutov
Subject: Re: Project local variables.
Date: Sun, 8 Nov 2020 03:48:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hi!

On 03.11.2020 21:41, Ergus wrote:

Looking at the evolution of project.el I want to know if there is any
sort of project local environment/namespace/scope. The idea is to
provide some variables that could be shared by all the files in the same
project but that could be modified by external-packages at the elisp
level. something like "setq-project"??

Something like project-set and project-get could be arranged (or perhaps just a project-session hash table). But given that the values won't persist between Emacs sessions, we'd have to consider to use cases first.

A use case is for example when working in tramp some operations are
expensive like looking for an executable in the remote system. The
search could be made only once; but then if a local file is open the
cached value will be wrong. The other case is to use the buffer-local
variables, but then it will need to be initialized once/per file every
time a file is open. Something that in my case affected performance
especially with lsp and elpy

Two things to consider: the performance of the operation you're trying to "cache", and the performance of 'project-current'.

The latter is not "free". And my near-term plan is to make project-try-vc slower by removing the vc-file-getprop/vc-file-setprop dance because it can lead to outdated information. Or at least try that and see which problems that brings.

In any case, what I'm saying is, 'project-current' on a remote host might not be fast either. Though it could be cached to at least only do the search once per user command.

Currently I am using a work-around with a global hash-table and a
variable definer in the dir-locals.el as a prefix, but maybe something
more elegant should/must be already implemented and I am not aware of??

Have you tried using (file-remote-p buffer-file-name) as the hash key?

If the operation to be sped up is really (executable-find "cat"), the result is really project-independent and should only depend on the host.

If there are other, actually project-dependent examples, the project-local variables (or "session cache", rather) could be implemented as a hash of hashes, keyed by project instance. There implementation seems like it will be rather trivial, but first I would like to know the use cases.



reply via email to

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