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