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: Mon, 05 Jun 2023 19:31:37 +0300 Organization: LINKOV.NET Message-ID: <86bkhtlvkm.fsf@mail.linkov.net> References: <86wn10e1wl.fsf@mail.linkov.net> <482a1ebc-165c-a0a4-98c0-5c404d1b1d0d@gutov.dev> <86jzwyxnxb.fsf@mail.linkov.net> <86o7m91z22.fsf@mail.linkov.net> <86pm6py6k4.fsf@mail.linkov.net> <86bki9y68h.fsf@mail.linkov.net> <86cz2f7bvo.fsf@mail.linkov.net> <86jzwipf4z.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="30460"; 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: Dmitry Gutov , 63648@debbugs.gnu.org, Spencer Baugh To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 05 18:41:39 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 1q6DH1-0007me-0M for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jun 2023 18:41:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6DGS-0004qX-EI; Mon, 05 Jun 2023 12:41:04 -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 1q6DGR-0004pC-00 for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:41:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6DGQ-0004ei-Ew for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q6DGQ-0004re-AT for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:41: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: Mon, 05 Jun 2023 16:41: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.168598321118617 (code B ref 63648); Mon, 05 Jun 2023 16:41:02 +0000 Original-Received: (at 63648) by debbugs.gnu.org; 5 Jun 2023 16:40:11 +0000 Original-Received: from localhost ([127.0.0.1]:50270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6DFa-0004qC-M4 for submit@debbugs.gnu.org; Mon, 05 Jun 2023 12:40:11 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:57813) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6DFY-0004pF-Ny for 63648@debbugs.gnu.org; Mon, 05 Jun 2023 12:40:09 -0400 X-GND-Sasl: juri@linkov.net X-GND-Sasl: juri@linkov.net X-GND-Sasl: juri@linkov.net X-GND-Sasl: juri@linkov.net Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id DE2CA240006; Mon, 5 Jun 2023 16:40:00 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Mon, 05 Jun 2023 10:44:11 -0400") 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:263025 Archived-At: >> (prefix-command-update) > > I think you need to call `prefix-command-preserve-state` as well, so > that the order of prefix commands doesn't matter (e.g. user can do `C-u > C-x p` instead of `C-x p C-u`). I confirm that after replacing `prefix-command-update` with `prefix-command-preserve-state` (replacing since the latter calls the former), now `C-u C-x p p f lisp/international/emoji-labels.el` works ok (without C-u it can't find this non-registered file). > [ Note: I'm still not really happy with the way prefix commands work. > I can't remember what problems are still lurking, but IIRC interaction > with minibuffer is a source of problems (e.g. prefix commands from > before we entered the minibuffer can affect operations within the > minibuffer and prefix commands from within the minibuffer can affect > the behavior after exiting the minibuffer). I think last time > I looked at it, I concluded that maybe it should be reimplemented such > that the state is kept in a single object to which prefix commands can > add/remove properties, and the minibuffer code would automatically > suspend and then reinstall that state (and could emit a warning when > throwing away "unused state", such as when leaving a minibuffer). ] I tested this with such test command and there are no problems: ``` (defun test (arg1 arg2) (interactive (list (progn (message "%S" default-directory) (read-string "1: ") (message "%S" default-directory)) (progn (message "%S" default-directory) (read-string "2: ") (message "%S" default-directory)))) (message "%S" default-directory)) ``` `C-x p p M-x test RET` prints only the new directory. However, I found a problem with `C-x p 4 p`. To fix it, `project-other-window-command` should be completely rewritten to: ``` (defun project-other-window-command () (interactive) (other-window-prefix) (set-transient-map (make-composed-keymap project-prefix-map project-other-window-map))) ``` plus a small fix that I don't know how to generalize: ``` diff --git a/lisp/window.el b/lisp/window.el index ab7dd5ced12..52ba407d9c8 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -9099,7 +9091,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-command command) + (memq this-command '(other-project-prefix))) (funcall exitfun)))) ;; Call post-function after the next command finishes (bug#49057). (add-hook 'post-command-hook postfun) ``` Then everything works as before and even better. >> If this is conceptually ok, then more customization could be ported >> from project--switch-project-command such as project-switch-use-entire-map. > > Looks OK to me [ modulo the fact that I don't really understand what > this is doing (I don't understand the `project-switch-commands` bit, nor > do I understand why a prefix command which temporarily changes the > `default-directory` would be called `project-switch-project`). ] It's possible to create another general command that will read arbitrary directory, but this command is project-specific with `project-prompter`. `project-switch-project` really should be renamed to `other-project-prefix` like other similar prefix commands. Here is the latest version without much changes: ``` (defun other-project-prefix (dir) (interactive (list (funcall project-prompter))) (if (symbolp project-switch-commands) (let ((default-directory dir)) (call-interactively project-switch-commands)) (let* ((echofun (lambda () "[switch-project]")) (postfun (lambda () (remove-hook 'prefix-command-echo-keystrokes-functions echofun)))) (setq next-default-directory dir) (message (project--keymap-prompt)) (add-hook 'prefix-command-echo-keystrokes-functions echofun) (prefix-command-preserve-state) (set-transient-map project-prefix-map nil postfun)))) ```