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

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

bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-proje


From: Dmitry Gutov
Subject: bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-project errors on non-project commands
Date: Wed, 13 Sep 2023 02:47:49 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

Hi Juri,

On 10/09/2023 18:30, Juri Linkov wrote:
So here is a complete tested patch that maintains backward-compatibility
with older versions, and is localized to project.el without the need to
discuss more fundamental changes on emacs-devel, and handles 100% of
known cases such as reported in bug#58784, bug#63829, etc.

It sounds like a possibly concise solution, but I'm still wrapping my head around it.

+(make-obsolete-variable
+ 'project-current-directory-override
+ 'project-current-directory-old
+ "30.1")

Aren't those variables sufficiently different that making one an alias for another would confuse things?

+(defvar-local project-current-directory-old nil
+  "Value to use instead of `default-directory' when detecting the project.
+For the next command after switching the project, this buffer-local
+variable contains the original value of `default-directory'.
+Whereas the buffer-local `default-directory' is temporarily set
+to the root directory of the switched project.
+When it is non-nil, `project-current' will always skip prompting too.")

The docstring is valuable, but I wonder how it looks to somebody from the outside trying to write code that would use it.

+                   (or (buffer-local-value 'project-current-directory-old buf)
+                       (buffer-local-value 'default-directory buf))))
...
+                (or (buffer-local-value 'project-current-directory-old buf)
+                    (buffer-local-value 'default-directory buf))))

So, this part looks like what we would be paying for this solution: any code looking to decide whether a buffer "belongs" to the project, would have to reproduce this exact expression. Wouldn't it?

+      (setq-local project-current-directory-old default-directory)
+      (setq-local default-directory dir)

Could you explain: if we can just set these here and then clean up in postfun, couldn't we likewise set (and then later clean up) the value of project-current-directory-override?

-                    (eq this-command command))
+                    (eq this-command command)
+                    (eq this-command 'other-project-prefix))

Did this part of the patch get in by accident? If it's "localized to project.el". Or do we have further plans to "generalize" that place somehow? Just making sure.





reply via email to

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