From e1e8da5e4f1951744d26b99b000c7f746a9ca8c6 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 why. (Bug#74166) --- lisp/tmm.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/tmm.el b/lisp/tmm.el index eeea1cf20be..632e55e47a8 100644 --- a/lisp/tmm.el +++ b/lisp/tmm.el @@ -336,6 +336,12 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." 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 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." (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 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." (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))