Commit 7f85a556 authored by Juri Linkov's avatar Juri Linkov

* lisp/tmm.el: Fix broken tmm-prompt (bug#34517)

* lisp/tmm.el (tmm-prompt): Don't duplicate items of tmm--history.
Don't reverse tmm-km-list for completion.  Don't set the initial
position of 'tmm--history.  Use reverse tmm--history as the list
of default values for M-n.
(tmm-add-prompt): Don't insert initial value to the minibuffer.
parent 034f9363
Pipeline #3085 failed with stage
in 67 minutes and 39 seconds
......@@ -240,8 +240,6 @@ instead of executing it."
(car elt)))
(setq history-len (length tmm--history))
(setq tmm--history (append tmm--history tmm--history
tmm--history tmm--history))
(setq tmm-c-prompt (nth (- history-len 1 index-of-default)
(setq out
......@@ -249,18 +247,17 @@ instead of executing it."
(car (nth index-of-default tmm-km-list))
(minibuffer-with-setup-hook #'tmm-add-prompt
;; tmm-km-list is reversed, because history
;; needs it in LIFO order. But completion
;; needs it in LIFO order. But default list
;; needs it in non-reverse order, so that the
;; menu items are displayed as completion
;; candidates in the order they are shown on
;; the menu bar. So pass completing-read the
;; menu items are displayed by M-n as default
;; values in the order they are shown on
;; the menu bar. So pass the DEFAULT arg the
;; reversed copy of the list.
(concat gl-str
" (up/down to change, PgUp to menu): ")
(tmm--completion-table (reverse tmm-km-list)) nil t nil
(cons 'tmm--history
(- (* 2 history-len) index-of-default))))))))
(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)
......@@ -404,8 +401,7 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
;; Try to show everything just inserted and preserve height of
;; *Completions* window. This should fix a behavior described
;; in Bug#1291.
(fit-window-to-buffer window nil nil nil nil t)))))
(insert tmm-c-prompt))
(fit-window-to-buffer window nil nil nil nil t))))))
(defun tmm-shortcut ()
"Choose the shortcut that the user typed."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment