Subject: bug#74166: closed (Re: bug#74166: [PATCH] Fix tmm "previous menu" shortcut)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 09 Nov 2024 10:36:02 +0000

Your bug report

#74166: [PATCH] Fix tmm "previous menu" shortcut

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74166: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74166
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74166: [PATCH] Fix tmm "previous menu" shortcut
From: Eli Zaretskii <[email-masked]>
To: Manuel Giraud <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 09 Nov 2024 12:34:58 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked]
> 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" <[email-masked]>
> 
> Juri Linkov <[email-masked]> 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.

Subject: [PATCH] Fix tmm "previous menu" shortcut
From: Manuel Giraud <[email-masked]>
To: [email-masked]
Date: Fri, 01 Nov 2024 19:36:00 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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'

>From 20cbb94b4c83a22d7d65578fab3a581a42836f56 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
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

-- 
Manuel Giraud