From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 09:47:09 +0300 Organization: LINKOV.NET Message-ID: <8634zitwoy.fsf@mail.linkov.net> References: <86o7m91z22.fsf@mail.linkov.net> <86pm6py6k4.fsf@mail.linkov.net> <86bki9y68h.fsf@mail.linkov.net> <86cz2f7bvo.fsf@mail.linkov.net> <86353axu48.fsf@mail.linkov.net> <87o7jfi00b.fsf@catern.com> <86msyhwrrg.fsf@mail.linkov.net> <86y1hs4kkg.fsf@mail.linkov.net> <86h6of66o3.fsf@mail.linkov.net> <86wmxb2qvh.fsf@mail.linkov.net> <8634zyjt0k.fsf@mail.linkov.net> <8d1fb7ac-5c82-0ec2-8ae2-d09c131ec165@gutov.dev> <86edj6hyem.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20927"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Spencer Baugh , 63648@debbugs.gnu.org, sbaugh@catern.com To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 08:57:27 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgJoT-00058O-Ey for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 08:57:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgJo3-0003Hz-JC; Wed, 13 Sep 2023 02:56:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgJo2-0003GM-5s for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 02:56:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgJo1-00033u-TV for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 02:56:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgJo6-00012p-IW for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 02:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 06:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63648 X-GNU-PR-Package: emacs Original-Received: via spool by 63648-submit@debbugs.gnu.org id=B63648.16945881733951 (code B ref 63648); Wed, 13 Sep 2023 06:57:02 +0000 Original-Received: (at 63648) by debbugs.gnu.org; 13 Sep 2023 06:56:13 +0000 Original-Received: from localhost ([127.0.0.1]:60578 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgJnI-00011a-MQ for submit@debbugs.gnu.org; Wed, 13 Sep 2023 02:56:13 -0400 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]:44915) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgJnC-00010y-8Z for 63648@debbugs.gnu.org; Wed, 13 Sep 2023 02:56:11 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 7AE861C0009; Wed, 13 Sep 2023 06:55:51 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Wed, 13 Sep 2023 02:47:49 +0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270253 Archived-At: >> 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? Indeed, during development I mistakenly made one an alias for another with 'define-obsolete-variable-alias', and this broke both variables. So I replaced it with 'make-obsolete-variable' that doesn't make an alias. It just designates it as obsolete to show the intention to remove it in later versions. >> +(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. I don't believe that someone might want to use this variable in more commands than the current project commands that rely on 'project-buffers'. But we could add a few more lines with explanations for them too. >> + (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? Then maybe this code should be moved to a separate function? >> + (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? We need to set 'default-directory' to support non-project commands. I already started to use this feature, and it becomes indispensable. For example, the most often used commands are vc commands such as 'C-x p p C-x v L' to see a vc log in another project, and 'C-x p p C-x v d' to open vc-dir, etc. >> - (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. This part is optional and could be generalized later.