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#70577: [PATCH] New command other-project-prefix Date: Wed, 22 May 2024 09:12:19 +0300 Organization: LINKOV.NET Message-ID: <86plte1jro.fsf@mail.linkov.net> References: <86le501ykg.fsf@mail.linkov.net> <86jzkhe81b.fsf@mail.linkov.net> <208c7a05-6cfe-40c2-af54-187967348686@gutov.dev> <86le4tz88d.fsf@mail.linkov.net> <865xvsjklh.fsf@mail.linkov.net> <861q6esvhl.fsf@mail.linkov.net> <938582b5-0f86-4cb0-8bfe-afb26af0e8c9@gutov.dev> <86eda4hpyh.fsf@mail.linkov.net> <1b247d37-d1da-462a-9582-f7f7ff689d8f@gutov.dev> <86fruja9bf.fsf@mail.linkov.net> <86jzjneoju.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="471"; 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: 70577@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 22 08:18:33 2024 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 1s9fJ2-000AX3-Ua for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 22 May 2024 08:18:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9fIW-00079A-9N; Wed, 22 May 2024 02:18:00 -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 1s9fIT-000735-9m for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 02:17: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 1s9fIT-0004y9-0D for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 02:17:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s9fIY-0006cW-JS for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 02:18: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, 22 May 2024 06:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70577 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70577-submit@debbugs.gnu.org id=B70577.171635865025415 (code B ref 70577); Wed, 22 May 2024 06:18:02 +0000 Original-Received: (at 70577) by debbugs.gnu.org; 22 May 2024 06:17:30 +0000 Original-Received: from localhost ([127.0.0.1]:53685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9fI2-0006bk-0g for submit@debbugs.gnu.org; Wed, 22 May 2024 02:17:30 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:54859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9fHx-0006bS-CI for 70577@debbugs.gnu.org; Wed, 22 May 2024 02:17:27 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id C2BA0C0006; Wed, 22 May 2024 06:17:11 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Tue, 21 May 2024 23:16:55 +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:285578 Archived-At: >> This works until I moved project-prompter to the beginning, >> then 'C-x 5 p p' doesn't work with this: >> (letrec ((root (funcall project-prompter)) >> (depth (minibuffer-depth)) >> (echofun (lambda () "[switch-project]")) >> (around-fun >> Maybe there is a better place? > > Last I checked, the project-prompter can change the value of this-command. > > Perhaps you can try a let-binding for this-command around the call to > project-prompter, so that it's restored at the end. This helps: (letrec ((root (let ((this-command this-command)) (funcall project-prompter))) > Something to also be concerned about is having any of the display-buffer > modifications, or other-project advices, get applied to one of the commands > inside the project-prompter UI (if it's implemented using a sequence of > commands). Perhaps I haven't triggered this case mostly by luck so far. How > to guard against that? Maybe a dynamic variable of some sort. But then it'd > also have to be checked uniformly in all such functions (hooks that prefix > commands install). This also helps: diff --git a/lisp/window.el b/lisp/window.el index 4147d7e6ebb..a4577d509b8 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -9252,7 +9279,7 @@ display-buffer-override-next-command ;; after the first display-buffer action (bug#39722). (funcall clearfun) new-window)))) - (command this-command) + (command this-original-command) (echofun (when echo (lambda () echo))) (exitfun (lambda () @@ -9274,7 +9301,8 @@ display-buffer-override-next-command (> (minibuffer-depth) minibuffer-depth) ;; But don't remove immediately after ;; adding the hook by the same command below. - (eq this-command command)) + (eq this-original-command command) + (get command 'prefix-command)) (funcall exitfun)))) ;; Call post-function after the next command finishes (bug#49057). (add-hook 'post-command-hook postfun) But not sure about the latter, it might break some cases.