From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73498: [PATCH] Add a shortcut to go up in the menu hierarchy. Date: Thu, 26 Sep 2024 13:27:24 +0200 Message-ID: <87cykqhcyr.fsf@ledu-giraud.fr> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24492"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 73498@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 26 13:28:56 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 1stmg4-0006Cb-6J for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Sep 2024 13:28:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stmfl-0007Dc-9i; Thu, 26 Sep 2024 07:28:37 -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 1stmfj-0007DN-JQ for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 07:28:35 -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 1stmfj-0003O4-7W for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 07:28:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=2KXCYYcNBKQ4lLwO4u9kLc8EFw+HrzFGQvO6bd1bLpM=; b=YkEjTnRfz+t8CW5iy2Vv4PpB2gbpDL+O8G85ntZzDYKQ/c2qmPvTBDjtj5TVMfnY7boD5kYLRyBMMlsTPdTxEZIioaNyhnPz/wrX+2IGgtcxhsYGf4U4wALRS5f/UZIA2Bq/xrw5wLvfbGFKrR7WT4xkqudn6Y7akJh/YIEE+qUlsTxbtpVP3v6eEFFR4ZyMJRtgwgK9iOGGWbq0fq0G8/OjMIDHta/89GlQK7TrgQiHYZuAbCZ/mdA2+2LbXcHfWGTMXLzyYvPGhLVZSJ99Il9C7bzgbsFT/3ARxda+R5T95Hoj4b4OgXFE2IsX1dtUDmZ3OcPjnt+rI8GWoCtwUA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stmgA-0008G4-77 for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 07:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Sep 2024 11:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73498 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172735012531700 (code B ref -1); Thu, 26 Sep 2024 11:29:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Sep 2024 11:28:45 +0000 Original-Received: from localhost ([127.0.0.1]:57552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stmfs-0008FD-M0 for submit@debbugs.gnu.org; Thu, 26 Sep 2024 07:28:45 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stmfp-0008F4-D6 for submit@debbugs.gnu.org; Thu, 26 Sep 2024 07:28:43 -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 1stmfO-0007BV-2C for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 07:28:14 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stmep-0003JK-7F for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2024 07:27:48 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=XgncRl1E uM2WaeAvfG25Ss07Ji8Ile0DgN33+aIetXo=; h=date:subject:to:from; d=ledu-giraud.fr; b=F5XDvU6hfYpd0jiyj+Oip49P6nomRjYw+43jYbh3OMMuL9YR6z QNqNdMH0Tt9tSjhqEY7HB46ESH6+KKoGdrCA== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=XgncRl1EuM2WaeAv fG25Ss07Ji8Ile0DgN33+aIetXo=; h=date:subject:to:from; d=ledu-giraud.fr; b=lRyYWmGC6aeRvHIjpuVGQhDfQpLmSytkvF871oDewKhNKz7+Nz xj2FyGXLxrp9wRhhDyKQbmF2ujk5qC65WUDgIwb3WNTs0xnCAa6o+eAh+JATgt76iuRR2D 0SlXJq3tBPC93d1tS4U6TAvftBabwKAP74StoEQYa09sdf3w/Nc8aztLmIxZUKy2Ya+5IY vbdv2n/X3y7nsL3s9NEgtql6BW3F3BZJXsKIQvvf2Ow5IRcUCN5CYTbLkpMc3kNAHDqam5 TwkPEBhqgZhm21wQ/fNHMrHiw0WCEscIURtQyvdzIiGpUhh1+EB7zmDMplwW0IGFIGpdfK FYd0KidCGOxg== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id e5576f1f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 26 Sep 2024 13:27:26 +0200 (CEST) Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:292454 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Hi, Here is a patch that add a shortcut (^) to `tmm-menubar' to go upward in the menu hierarchy. In GNU Emacs 31.0.50 (build 4, x86_64-unknown-openbsd7.6) of 2024-09-21 built on computer Repository revision: 4745bafa6a1d6aeda5ad08e09541d076ee223382 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101013 System Description: OpenBSD computer 7.6 GENERIC.MP#321 amd64 Configured using: 'configure CC=egcc CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs --bindir=/home/manuel/bin --with-x-toolkit=no --with-toolkit-scroll-bars=no --without-cairo --without-compress-install' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-a-shortcut-to-go-up-in-the-menu-hierarchy.patch >From f86caa4cf06801c1917247519a16594b8fad9de9 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Wed, 25 Sep 2024 10:31:12 +0200 Subject: [PATCH] Add a shortcut to go up in the menu hierarchy. * lisp/tmm.el (tmm-prompt): Add a shortcut to go up in the menu hierarchy. (tmm-completion-prompt): Document it in help message. (tmm-define-keys): Add the shortcut in the keymap. --- lisp/tmm.el | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/lisp/tmm.el b/lisp/tmm.el index f52afb7e162..444d7945987 100644 --- a/lisp/tmm.el +++ b/lisp/tmm.el @@ -88,8 +88,9 @@ tmm-mb-map (defcustom tmm-completion-prompt "Press PageUp key to reach this buffer from the minibuffer. Alternatively, you can use Up/Down keys (or your History keys) to change -the item in the minibuffer, and press RET when you are done, or press the -marked letters to pick up your choice. Type C-g or ESC ESC ESC to cancel. +the item in the minibuffer, and press RET when you are done, or press +the marked letters to pick up your choice. Type ^ to go to the parent +menu. Type C-g or ESC ESC ESC to cancel. " "Help text to insert on the top of the completion buffer. To save space, you can set this to nil, @@ -123,7 +124,7 @@ tmm--completion-table (defvar tmm--history nil) ;;;###autoload -(defun tmm-prompt (menu &optional in-popup default-item no-execute) +(defun tmm-prompt (menu &optional in-popup default-item no-execute path) "Text-mode emulation of calling the bindings in keymap. Creates a text-mode menu of possible choices. You can access the elements in the menu in two ways: @@ -136,7 +137,9 @@ tmm-prompt DEFAULT-ITEM, if non-nil, specifies an initial default choice. Its value should be an event that has a binding in MENU. NO-EXECUTE, if non-nil, means to return the command the user selects -instead of executing it." +instead of executing it. +PATH is a stack that keeps track your path into sub-menus. It is used +to go back in the menu hierarchy." ;; If the optional argument IN-POPUP is t, ;; then MENU is an alist of elements of the form (STRING . VALUE). ;; That is used for recursive calls only. @@ -227,22 +230,28 @@ tmm-prompt " (up/down to change, PgUp to menu): ") (tmm--completion-table tmm-km-list) nil t nil 'tmm--history (reverse tmm--history))))))) - (setq choice (cdr (assoc out tmm-km-list))) - (and (null choice) - (string-prefix-p tmm-c-prompt out) - (setq out (substring out (length tmm-c-prompt)) - choice (cdr (assoc out tmm-km-list)))) - (and (null choice) out - (setq out (try-completion out tmm-km-list) - choice (cdr (assoc out tmm-km-list))))) + (if (and (stringp out) (string= "^" out)) + ;; a fake choice to please the destructuring later. + (setq choice (cons out out)) + (setq choice (cdr (assoc out tmm-km-list))) + (and (null choice) + (string-prefix-p tmm-c-prompt out) + (setq out (substring out (length tmm-c-prompt)) + choice (cdr (assoc out tmm-km-list)))) + (and (null choice) out + (setq out (try-completion out tmm-km-list) + choice (cdr (assoc out tmm-km-list)))))) ;; CHOICE is now (STRING . MEANING). Separate the two parts. (setq chosen-string (car choice)) (setq choice (cdr choice)) - (cond (in-popup + (cond ((and (stringp choice) (string= "^" choice)) + ;; User wants to go up: do it first. + (if path (tmm-prompt (pop path) in-popup nil nil path))) + (in-popup ;; We just did the inner level of a -popup menu. choice) ;; We just did the outer level. Do the inner level now. - (not-menu (tmm-prompt choice t nil no-execute)) + (not-menu (tmm-prompt choice t nil no-execute (cons menu path))) ;; We just handled a menu keymap and found another keymap. ((keymapp choice) (if (symbolp choice) @@ -250,7 +259,7 @@ tmm-prompt (condition-case nil (require 'mouse) (error nil)) - (tmm-prompt choice nil nil no-execute)) + (tmm-prompt choice nil nil no-execute (cons menu path))) ;; We just handled a menu keymap and found a command. (choice (if chosen-string @@ -322,7 +331,8 @@ tmm-define-keys (define-key map [prior] 'tmm-goto-completions) (define-key map "\ev" 'tmm-goto-completions) (define-key map "\C-n" 'next-history-element) - (define-key map "\C-p" 'previous-history-element))) + (define-key map "\C-p" 'previous-history-element) + (define-key map "^" 'self-insert-and-exit))) (prog1 (current-local-map) (use-local-map (append map (current-local-map)))))) -- 2.46.1 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--