]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tmm.el: Fix broken tmm-prompt (bug#34517)
authorJuri Linkov <juri@linkov.net>
Sun, 8 Sep 2019 20:27:23 +0000 (23:27 +0300)
committerJuri Linkov <juri@linkov.net>
Sun, 8 Sep 2019 20:27:23 +0000 (23:27 +0300)
* 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.

lisp/tmm.el

index bf76652f401f37a817a79a2e05263a75aaa4111b..c1c863876b542bef31ed9f21430a620d064690c0 100644 (file)
@@ -240,8 +240,6 @@ instead of executing it."
                                            (car elt)))
                                      tmm-km-list)))))
             (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)
                                      tmm--history))
              (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.
                        (completing-read-default
                         (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."