diff options
| author | Eli Zaretskii | 2016-04-19 18:06:52 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-04-19 18:06:52 +0300 |
| commit | ce0d8c7f2d8187942a8b45c3a71c22c5f30fa37d (patch) | |
| tree | a483783b2891ae39f6427fbbba652549eb715096 /lisp | |
| parent | b8d5a8fd1a16a30ac42883bfea3f25ecef1e7fde (diff) | |
| download | emacs-ce0d8c7f2d8187942a8b45c3a71c22c5f30fa37d.tar.gz emacs-ce0d8c7f2d8187942a8b45c3a71c22c5f30fa37d.zip | |
Make tmm-menubar work in correct order again
* lisp/tmm.el (tmm-prompt): Don't reverse 'tmm-km-list' right at the
beginning; instead, pass a reversed copy to 'tmm--completion-table'.
(Bug#23309)
(tmm-menubar): Fix an off-by-one error in determining the menu
item when the function is called with a non-nil 'x-position'
argument.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/tmm.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lisp/tmm.el b/lisp/tmm.el index 714de9230e7..d1a08ab2623 100644 --- a/lisp/tmm.el +++ b/lisp/tmm.el | |||
| @@ -72,13 +72,15 @@ to invoke `tmm-menubar' instead, customize the variable | |||
| 72 | (tmm-get-keybind [menu-bar])) | 72 | (tmm-get-keybind [menu-bar])) |
| 73 | (setq menu-bar `(keymap ,@(nreverse menu-bar) ,@(nreverse menu-end))) | 73 | (setq menu-bar `(keymap ,@(nreverse menu-bar) ,@(nreverse menu-end))) |
| 74 | (if x-position | 74 | (if x-position |
| 75 | (let ((column 0)) | 75 | (let ((column 0) |
| 76 | prev-key) | ||
| 76 | (catch 'done | 77 | (catch 'done |
| 77 | (map-keymap | 78 | (map-keymap |
| 78 | (lambda (key binding) | 79 | (lambda (key binding) |
| 79 | (when (> column x-position) | 80 | (when (> column x-position) |
| 80 | (setq menu-bar-item key) | 81 | (setq menu-bar-item prev-key) |
| 81 | (throw 'done nil)) | 82 | (throw 'done nil)) |
| 83 | (setq prev-key key) | ||
| 82 | (pcase binding | 84 | (pcase binding |
| 83 | ((or `(,(and (pred stringp) name) . ,_) ;Simple menu item. | 85 | ((or `(,(and (pred stringp) name) . ,_) ;Simple menu item. |
| 84 | `(menu-item ,name ,_cmd ;Extended menu item. | 86 | `(menu-item ,name ,_cmd ;Extended menu item. |
| @@ -187,7 +189,6 @@ Its value should be an event that has a binding in MENU." | |||
| 187 | ((vectorp elt) | 189 | ((vectorp elt) |
| 188 | (dotimes (i (length elt)) | 190 | (dotimes (i (length elt)) |
| 189 | (tmm-get-keymap (cons i (aref elt i)) not-menu)))))) | 191 | (tmm-get-keymap (cons i (aref elt i)) not-menu)))))) |
| 190 | (setq tmm-km-list (nreverse tmm-km-list)) | ||
| 191 | ;; Choose an element of tmm-km-list; put it in choice. | 192 | ;; Choose an element of tmm-km-list; put it in choice. |
| 192 | (if (and not-menu (= 1 (length tmm-km-list))) | 193 | (if (and not-menu (= 1 (length tmm-km-list))) |
| 193 | ;; If this is the top-level of an x-popup-menu menu, | 194 | ;; If this is the top-level of an x-popup-menu menu, |
| @@ -239,10 +240,17 @@ Its value should be an event that has a binding in MENU." | |||
| 239 | (if default-item | 240 | (if default-item |
| 240 | (car (nth index-of-default tmm-km-list)) | 241 | (car (nth index-of-default tmm-km-list)) |
| 241 | (minibuffer-with-setup-hook #'tmm-add-prompt | 242 | (minibuffer-with-setup-hook #'tmm-add-prompt |
| 243 | ;; tmm-km-list is reversed, because history | ||
| 244 | ;; needs it in LIFO order. But completion | ||
| 245 | ;; needs it in non-reverse order, so that the | ||
| 246 | ;; menu items are displayed as completion | ||
| 247 | ;; candidates in the order they are shown on | ||
| 248 | ;; the menu bar. So pass completing-read the | ||
| 249 | ;; reversed copy of the list. | ||
| 242 | (completing-read | 250 | (completing-read |
| 243 | (concat gl-str | 251 | (concat gl-str |
| 244 | " (up/down to change, PgUp to menu): ") | 252 | " (up/down to change, PgUp to menu): ") |
| 245 | (tmm--completion-table tmm-km-list) nil t nil | 253 | (tmm--completion-table (reverse tmm-km-list)) nil t nil |
| 246 | (cons 'tmm--history | 254 | (cons 'tmm--history |
| 247 | (- (* 2 history-len) index-of-default)))))))) | 255 | (- (* 2 history-len) index-of-default)))))))) |
| 248 | (setq choice (cdr (assoc out tmm-km-list))) | 256 | (setq choice (cdr (assoc out tmm-km-list))) |