From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov 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: Thu, 26 Oct 2023 01:26:52 +0300 Message-ID: References: <86edj6hyem.fsf@mail.linkov.net> <8634zitwoy.fsf@mail.linkov.net> <50d46d30-a796-b855-0d4c-690d6cb3d15b@gutov.dev> <86il88x9cy.fsf@mail.linkov.net> <4367c45c-95b3-6a29-4ba3-068a3c748452@gutov.dev> <2e34e515-a921-a969-0915-bea94c745f8b@gutov.dev> <868r9258oi.fsf@mail.linkov.net> <86edishisp.fsf@mail.linkov.net> <6fc81cbf-a21f-c5b4-aa56-e8518b8570d7@gutov.dev> <86msxgatuy.fsf@mail.linkov.net> <86y1gynr2u.fsf@mail.linkov.net> <7c72fd8c-c3f6-a974-8a4b-a081f7a9fe1a@gutov.dev> <86ttqmv7c6.fsf@mail.linkov.net> <56e7d865-0456-db7d-3a5d-1235e62508bf@gutov.dev> <865y31onju.fsf@mail.linkov.net> <8562bdad-e487-886a-af49-7f67d8d14b7a@gutov.dev> <86msw9g5yb.fsf@mail.linkov.net> <56909bdd-14ee-f68c-178f-5057efcd6150@gutov.dev> <86wmva7iey.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------OCO24ptx9HbRJUVDT6K3X4E6" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25168"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: Spencer Baugh , 63648@debbugs.gnu.org, sbaugh@catern.com To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 26 00:27:54 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 1qvmLx-0006Iu-Sh for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Oct 2023 00:27:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvmLe-0004vl-H5; Wed, 25 Oct 2023 18:27:34 -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 1qvmLd-0004vK-1a for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 18:27:33 -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 1qvmLc-0001Ac-DI for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 18:27:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qvmM6-00063K-EG for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 18:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Oct 2023 22:28: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.169827285923227 (code B ref 63648); Wed, 25 Oct 2023 22:28:02 +0000 Original-Received: (at 63648) by debbugs.gnu.org; 25 Oct 2023 22:27:39 +0000 Original-Received: from localhost ([127.0.0.1]:60172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvmLi-00062W-NN for submit@debbugs.gnu.org; Wed, 25 Oct 2023 18:27:39 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:36947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvmLd-00062C-Jv for 63648@debbugs.gnu.org; Wed, 25 Oct 2023 18:27:37 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id C10BE320015C; Wed, 25 Oct 2023 18:26:56 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 25 Oct 2023 18:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1698272816; x=1698359216; bh=7W /BTWGxZAwrKTwIqtYLSHuuqYLK2IldCgCfqhLYf5Y=; b=F12c35QpfOCqU3Xa68 oPuoK7ahDQYw0YlNsEMyop0ckj4UNMsFTBl4TaUqwrz31gnbuD7s0hxDhV0GB1pn kxMO9AG9+78sKFoYiffKaNh/GxBgS3USSergDj4OLBqLVrrKezh8+b+ibhGc4yPQ mhM2dxc5jvmFKeRHwqMDstDmOT7Uj7+b2vhrhrKKAumYrl4y9gJJcLS+/7v0qJ9a AY7wTmLni7aMJzfabof9AsCVYlnnrJ9poZJv4JgThO+gEDFvfEw6xHhd9V68ud+z cvLSzcbGYszFSpFAFJwglQ3NXg/zB7IaVv8rXQDVwuhu5ANQHWmlMCwIrNWnCnu2 t5Xw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698272816; x=1698359216; bh=7W/BTWGxZAwrK TwIqtYLSHuuqYLK2IldCgCfqhLYf5Y=; b=aur3Y5sI3YxDxD5W6vDDuTKZR83Xn KqANi2dXz3h+Wc1XtC9acAoba7y8ny4YdguQ0xG5/0OFWaNZqncawRaAWfrrO+7o MAVnykr195Vf1ldifmo3An7j2ppo6Z83Vk9DIwVJLharRJ2MeAR7F5drDIEnPC6l Ma/kExW2AqYumEG73GhY2vGGCpNOd/8vyXkOzv8o+PgqJpGP6vpwzcMhi2kNQQj2 SMjLiCs4T5zGpYytMuiBDlVo9fvVYvisaTFvNTMTYtaQo8n+wnXkBR5XELo1kT7a srgrOONL3Y6+zjkYgW7BkXDJK3KISjbY00udS2IfimP45py2E67LzB0vg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrledugddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpegtkfffgggfuffvvehfhfgjsehmtderredtfeejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhepheetkefgteeiueejuedvtddvleetffeljeetuddvfeffjeeiheehueetffevieej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmih htrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Oct 2023 18:26:54 -0400 (EDT) Content-Language: en-US In-Reply-To: <86wmva7iey.fsf@mail.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:273217 Archived-At: This is a multi-part message in MIME format. --------------OCO24ptx9HbRJUVDT6K3X4E6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 25/10/2023 19:53, Juri Linkov wrote: >> + ;; Variation: could be a separate command, or an option. >> + ;; (command (let ((overriding-local-map project-prefix-map)) >> + ;; (key-binding (read-key-sequence >> + ;; (format "[execute in %s]:" (project-root pr))) >> + ;; t))) > > Thanks, it works nicely. > Any reason not to use this by default? Nothing critical, but it might not fit the expectations without additional instructions in the prompt, or it can be unnecessary if the user had reached this command through 'C-x p o'. In the latter case there is also a small chance that the user had set up some advanced sub-maps inside project-prefix-map which would shadow some global bindings. So maybe a separate command is best. Please see how you like the attached new version together with (setq project-switch-commands #'project-prefix-or-any-command) I'm not sure about project-prefix-or-any-command's prompt, though (phrasing feels awkward). Improvements welcome. >> + (if found >> + (let ((project-current-directory-override root)) >> + (call-interactively command)) >> + (let ((default-directory root)) >> + (call-interactively command)))))) > > Not sure why need to let-bind project-current-directory-override here. > It seems to work with and without it. You mean with found=nil? Indeed, rebinding project-current-directory-override instead of just doing that with default-directory is critical for only a small subset of commands (such as project-switch-buffer or bug#58784). So this will be a 99% solution that, however, leads to more straightforward code. BTW, let me know if you prefer the "prefix command" style from your last patch for this command. My main sticking point with it was the change of logic used to indicate a different project root, but it can just as well be transplanted there. So if the prefix command approach is better for some scenarios, we can switch to it. --------------OCO24ptx9HbRJUVDT6K3X4E6 Content-Type: text/x-patch; charset=UTF-8; name="project-other-command-v4.diff" Content-Disposition: attachment; filename="project-other-command-v4.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZ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lIGFnYWlu c3QgIlxcYHByb2plY3QtIiwKKyAgICAgIDs7IGFuZC9vciAoZ2V0IGNvbW1hbmQgJ3Byb2pl Y3QtY29tbWFuZCkuCisgICAgICAobWFwLWtleW1hcAorICAgICAgIChsYW1iZGEgKF9ldnQg Y21kKSAoaWYgKGVxIGNtZCBjb21tYW5kKSAoc2V0cSBmb3VuZCB0KSkpCisgICAgICAgcHJv amVjdC1wcmVmaXgtbWFwKQorICAgICAgKGlmIGZvdW5kCisgICAgICAgICAgKGxldCAoKHBy b2plY3QtY3VycmVudC1kaXJlY3Rvcnktb3ZlcnJpZGUgcm9vdCkpCisgICAgICAgICAgICAo Y2FsbC1pbnRlcmFjdGl2ZWx5IGNvbW1hbmQpKQorICAgICAgICAobGV0ICgoZGVmYXVsdC1k aXJlY3Rvcnkgcm9vdCkpCisgICAgICAgICAgKGNhbGwtaW50ZXJhY3RpdmVseSBjb21tYW5k KSkpKSkpCisKKzs7OyMjI2F1dG9sb2FkCisoZGVmdW4gcHJvamVjdC1wcmVmaXgtb3ItYW55 LWNvbW1hbmQgKCkKKyAgIlJ1biB0aGUgbmV4dCBjb21tYW5kIGluIHRoZSBjdXJyZW50IHBy b2plY3QuCitXb3JrcyBsaWtlIGBwcm9qZWN0LWFueS1jb21tYW5kJywgYnV0IGFsc28gbWl4 ZXMgaW4gdGhlIHNob3J0ZXIKK2JpbmRpbmdzIGZyb20gYHByb2plY3QtcHJlZml4LW1hcCcu IgorICAoaW50ZXJhY3RpdmUpCisgIChwcm9qZWN0LWFueS1jb21tYW5kIHByb2plY3QtcHJl Zml4LW1hcAorICAgICAgICAgICAgICAgICAgICAgICAoY29uY2F0CisgICAgICAgICAgICAg ICAgICAgICAgICAiW2luICVzXSBQcmVzcyAiCisgICAgICAgICAgICAgICAgICAgICAgICAo cHJvamVjdC0ta2V5bWFwLXByb21wdCkKKyAgICAgICAgICAgICAgICAgICAgICAgICIgb3Ig b3RoZXI6IikpKQorCiAoZGVmdW4gcHJvamVjdC1yZW1lbWJlci1wcm9qZWN0cy11bmRlciAo ZGlyICZvcHRpb25hbCByZWN1cnNpdmUpCiAgICJJbmRleCBhbGwgcHJvamVjdHMgYmVsb3cg YSBkaXJlY3RvcnkgRElSLgogSWYgUkVDVVJTSVZFIGlzIG5vbi1uaWwsIHJlY3Vyc2UgaW50 byBhbGwgc3ViZGlyZWN0b3JpZXMgdG8gZmluZApAQCAtMTg5MSw3ICsxOTM2LDggQEAgcHJv amVjdC1zd2l0Y2gtY29tbWFuZHMKICAgICAocHJvamVjdC1maW5kLXJlZ2V4cCAiRmluZCBy ZWdleHAiKQogICAgIChwcm9qZWN0LWZpbmQtZGlyICJGaW5kIGRpcmVjdG9yeSIpCiAgICAg KHByb2plY3QtdmMtZGlyICJWQy1EaXIiKQotICAgIChwcm9qZWN0LWVzaGVsbCAiRXNoZWxs IikpCisgICAgKHByb2plY3QtZXNoZWxsICJFc2hlbGwiKQorICAgIChwcm9qZWN0LWFueS1j b21tYW5kICJPdGhlciIpKQogICAiQWxpc3QgbWFwcGluZyBjb21tYW5kcyB0byBkZXNjcmlw dGlvbnMuCiBVc2VkIGJ5IGBwcm9qZWN0LXN3aXRjaC1wcm9qZWN0JyB0byBjb25zdHJ1Y3Qg YSBkaXNwYXRjaCBtZW51IG9mCiBjb21tYW5kcyBhdmFpbGFibGUgdXBvbiBcInN3aXRjaGlu Z1wiIHRvIGFub3RoZXIgcHJvamVjdC4K --------------OCO24ptx9HbRJUVDT6K3X4E6--