* bug#74166: [PATCH] Fix tmm "previous menu" shortcut
@ 2024-11-01 18:36 Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-02 17:10 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-01 18:36 UTC (permalink / raw)
To: 74166
[-- Attachment #1: Type: text/plain, Size: 971 bytes --]
Tags: patch
Hi,
The following patch fixes the "previous menu" shortcut in tmm-menubar
when one has already used Up/Down keys into a submenu.
How to reproduce the bug:
- M-x tmm-menubar
- t ;; for the Tools menu
- Down ;; to circulate to the first entry
- ^ ;; quits tmm but should go back to toplevel instead
While here, explain a "Why?" comment.
In GNU Emacs 31.0.50 (build 86, x86_64-unknown-openbsd7.6, X toolkit) of
2024-11-01 built on computer
Repository revision: ffda8dfe847094bd8488059be2f96270fe298fa5
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: OpenBSD computer 7.6 GENERIC.MP#394 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=lucid
--with-toolkit-scroll-bars=no --without-cairo
--without-compress-install'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-tmm-previous-menu-shortcut.patch --]
[-- Type: text/patch, Size: 1825 bytes --]
From 20cbb94b4c83a22d7d65578fab3a581a42836f56 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 1 Nov 2024 19:27:31 +0100
Subject: [PATCH] Fix tmm "previous menu" shortcut
* lisp/tmm.el (tmm-clear-self-insert-and-exit): New function to
clear the minibuffer content then call `self-insert-and-exit'.
(tmm-define-keys): Use it.
(tmm-goto-completions): Explain a why.
---
lisp/tmm.el | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lisp/tmm.el b/lisp/tmm.el
index 80991b246b6..cf34f643c3b 100644
--- a/lisp/tmm.el
+++ b/lisp/tmm.el
@@ -336,6 +336,12 @@ tmm-add-one-shortcut
str))
(cdr elt))))))
+(defun tmm-clear-self-insert-and-exit ()
+ "Clear the minibuffer content before self insert and exit."
+ (interactive)
+ (delete-region (minibuffer-prompt-end) (point-max))
+ (self-insert-and-exit))
+
;; This returns the old map.
(defun tmm-define-keys (minibuffer)
(let ((map (make-sparse-keymap)))
@@ -354,7 +360,7 @@ tmm-define-keys
(define-key map "\C-n" 'next-history-element)
(define-key map "\C-p" 'previous-history-element)
;; Previous menu shortcut (see `tmm-prompt').
- (define-key map "^" 'self-insert-and-exit))
+ (define-key map "^" 'tmm-clear-self-insert-and-exit))
(prog1 (current-local-map)
(use-local-map (append map (current-local-map))))))
@@ -454,7 +460,8 @@ tmm-goto-completions
(interactive)
(let ((prompt-end (minibuffer-prompt-end)))
(setq tmm-c-prompt (buffer-substring prompt-end (point-max)))
- ;; FIXME: Why?
+ ;; Clear minibuffer old content before using *Completions* buffer
+ ;; for selection.
(delete-region prompt-end (point-max)))
(switch-to-buffer-other-window "*Completions*")
(search-forward tmm-c-prompt)
--
2.47.0
[-- Attachment #3: Type: text/plain, Size: 18 bytes --]
--
Manuel Giraud
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#74166: [PATCH] Fix tmm "previous menu" shortcut
2024-11-01 18:36 bug#74166: [PATCH] Fix tmm "previous menu" shortcut Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-02 17:10 ` Juri Linkov
2024-11-02 18:43 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2024-11-02 17:10 UTC (permalink / raw)
To: Manuel Giraud; +Cc: 74166
> +(defun tmm-clear-self-insert-and-exit ()
> + "Clear the minibuffer content before self insert and exit."
> + (interactive)
> + (delete-region (minibuffer-prompt-end) (point-max))
> + (self-insert-and-exit))
There is a special function 'delete-minibuffer-contents'
like is used e.g. in 'read-char-from-minibuffer-insert-char'
and 'y-or-n-p-insert-y'.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#74166: [PATCH] Fix tmm "previous menu" shortcut
2024-11-02 17:10 ` Juri Linkov
@ 2024-11-02 18:43 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 10:34 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-02 18:43 UTC (permalink / raw)
To: Juri Linkov; +Cc: 74166
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
Juri Linkov <juri@linkov.net> writes:
>> +(defun tmm-clear-self-insert-and-exit ()
>> + "Clear the minibuffer content before self insert and exit."
>> + (interactive)
>> + (delete-region (minibuffer-prompt-end) (point-max))
>> + (self-insert-and-exit))
>
> There is a special function 'delete-minibuffer-contents'
> like is used e.g. in 'read-char-from-minibuffer-insert-char'
> and 'y-or-n-p-insert-y'.
Thanks. Here is a new version that uses this.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-tmm-previous-menu-shortcut.patch --]
[-- Type: text/x-patch, Size: 2022 bytes --]
From c4f2e844b6c9008f2a176f95a20b0f3caf0b9710 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 1 Nov 2024 19:27:31 +0100
Subject: [PATCH] Fix tmm "previous menu" shortcut
Bug#74166
* lisp/tmm.el (tmm-clear-self-insert-and-exit): New function to
clear the minibuffer content then call `self-insert-and-exit'.
(tmm-define-keys): Use it.
(tmm-goto-completions): Explain a why.
---
lisp/tmm.el | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lisp/tmm.el b/lisp/tmm.el
index 80991b246b6..c73eb8c637e 100644
--- a/lisp/tmm.el
+++ b/lisp/tmm.el
@@ -336,6 +336,12 @@ tmm-add-one-shortcut
str))
(cdr elt))))))
+(defun tmm-clear-self-insert-and-exit ()
+ "Clear the minibuffer contents then self insert and exit."
+ (interactive)
+ (delete-minibuffer-contents)
+ (self-insert-and-exit))
+
;; This returns the old map.
(defun tmm-define-keys (minibuffer)
(let ((map (make-sparse-keymap)))
@@ -354,7 +360,7 @@ tmm-define-keys
(define-key map "\C-n" 'next-history-element)
(define-key map "\C-p" 'previous-history-element)
;; Previous menu shortcut (see `tmm-prompt').
- (define-key map "^" 'self-insert-and-exit))
+ (define-key map "^" 'tmm-clear-self-insert-and-exit))
(prog1 (current-local-map)
(use-local-map (append map (current-local-map))))))
@@ -452,10 +458,10 @@ tmm-shortcut
(defun tmm-goto-completions ()
"Jump to the completions buffer."
(interactive)
- (let ((prompt-end (minibuffer-prompt-end)))
- (setq tmm-c-prompt (buffer-substring prompt-end (point-max)))
- ;; FIXME: Why?
- (delete-region prompt-end (point-max)))
+ (setq tmm-c-prompt (buffer-substring (minibuffer-prompt-end) (point-max)))
+ ;; Clear minibuffer old contents before using *Completions* buffer for
+ ;; selection.
+ (delete-minibuffer-contents)
(switch-to-buffer-other-window "*Completions*")
(search-forward tmm-c-prompt)
(search-backward tmm-c-prompt))
--
2.47.0
[-- Attachment #3: Type: text/plain, Size: 18 bytes --]
--
Manuel Giraud
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#74166: [PATCH] Fix tmm "previous menu" shortcut
2024-11-02 18:43 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-09 10:34 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-11-09 10:34 UTC (permalink / raw)
To: Manuel Giraud; +Cc: 74166-done, juri
> Cc: 74166@debbugs.gnu.org
> Date: Sat, 02 Nov 2024 19:43:33 +0100
> From: Manuel Giraud via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> Juri Linkov <juri@linkov.net> writes:
>
> >> +(defun tmm-clear-self-insert-and-exit ()
> >> + "Clear the minibuffer content before self insert and exit."
> >> + (interactive)
> >> + (delete-region (minibuffer-prompt-end) (point-max))
> >> + (self-insert-and-exit))
> >
> > There is a special function 'delete-minibuffer-contents'
> > like is used e.g. in 'read-char-from-minibuffer-insert-char'
> > and 'y-or-n-p-insert-y'.
>
> Thanks. Here is a new version that uses this.
Thanks, installed on the master branch, and closing the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-09 10:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-01 18:36 bug#74166: [PATCH] Fix tmm "previous menu" shortcut Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-02 17:10 ` Juri Linkov
2024-11-02 18:43 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 10:34 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).