diff options
| author | Stefan Monnier | 2010-05-11 16:07:12 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-05-11 16:07:12 -0400 |
| commit | dc9ed7949681bcb29cf151c5183efcc50260fa00 (patch) | |
| tree | 7586fb9eedf3ce21e52395e91db0324e17e17bc8 | |
| parent | c8670ded9c8c4fe3801b6a378ee93f9180ce0453 (diff) | |
| download | emacs-dc9ed7949681bcb29cf151c5183efcc50260fa00.tar.gz emacs-dc9ed7949681bcb29cf151c5183efcc50260fa00.zip | |
Backport from trunk: compute shortcuts in tmm.el.
* tmm.el (tmm-prompt): Don't try to precompute bindings.
(tmm-get-keymap): Compute shortcuts since the cache is empty.
Fixes: debbugs:6171
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/tmm.el | 50 |
2 files changed, 29 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 90c3d0de1a0..6ac83cdb0c2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-05-11 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * tmm.el (tmm-prompt): Don't try to precompute bindings. | ||
| 4 | (tmm-get-keymap): Compute shortcuts (bug#6171). | ||
| 5 | |||
| 1 | 2010-05-10 Glenn Morris <rgm@gnu.org> | 6 | 2010-05-10 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * desktop.el (desktop-save-buffer-p): Don't mistakenly include | 8 | * desktop.el (desktop-save-buffer-p): Don't mistakenly include |
diff --git a/lisp/tmm.el b/lisp/tmm.el index f4ae3c110d5..0cbc72673a4 100644 --- a/lisp/tmm.el +++ b/lisp/tmm.el | |||
| @@ -262,9 +262,6 @@ Its value should be an event that has a binding in MENU." | |||
| 262 | (condition-case nil | 262 | (condition-case nil |
| 263 | (require 'mouse) | 263 | (require 'mouse) |
| 264 | (error nil)) | 264 | (error nil)) |
| 265 | (condition-case nil | ||
| 266 | (x-popup-menu nil choice) ; Get the shortcuts | ||
| 267 | (error nil)) | ||
| 268 | (tmm-prompt choice)) | 265 | (tmm-prompt choice)) |
| 269 | ;; We just handled a menu keymap and found a command. | 266 | ;; We just handled a menu keymap and found a command. |
| 270 | (choice | 267 | (choice |
| @@ -445,33 +442,30 @@ element of keymap, an `x-popup-menu' argument, or an element of | |||
| 445 | `x-popup-menu' argument (when IN-X-MENU is not-nil). | 442 | `x-popup-menu' argument (when IN-X-MENU is not-nil). |
| 446 | This function adds the element only if it is not already present. | 443 | This function adds the element only if it is not already present. |
| 447 | It uses the free variable `tmm-table-undef' to keep undefined keys." | 444 | It uses the free variable `tmm-table-undef' to keep undefined keys." |
| 448 | (let (km str cache plist filter visible enable (event (car elt))) | 445 | (let (km str plist filter visible enable (event (car elt))) |
| 449 | (setq elt (cdr elt)) | 446 | (setq elt (cdr elt)) |
| 450 | (if (eq elt 'undefined) | 447 | (if (eq elt 'undefined) |
| 451 | (setq tmm-table-undef (cons (cons event nil) tmm-table-undef)) | 448 | (setq tmm-table-undef (cons (cons event nil) tmm-table-undef)) |
| 452 | (unless (assoc event tmm-table-undef) | 449 | (unless (assoc event tmm-table-undef) |
| 453 | (cond ((if (listp elt) | 450 | (cond ((if (listp elt) |
| 454 | (or (keymapp elt) (eq (car elt) 'lambda)) | 451 | (or (keymapp elt) (eq (car elt) 'lambda)) |
| 455 | (fboundp elt)) | 452 | (and (symbolp elt) (fboundp elt))) |
| 456 | (setq km elt)) | 453 | (setq km elt)) |
| 457 | 454 | ||
| 458 | ((if (listp (cdr-safe elt)) | 455 | ((if (listp (cdr-safe elt)) |
| 459 | (or (keymapp (cdr-safe elt)) | 456 | (or (keymapp (cdr-safe elt)) |
| 460 | (eq (car (cdr-safe elt)) 'lambda)) | 457 | (eq (car (cdr-safe elt)) 'lambda)) |
| 461 | (fboundp (cdr-safe elt))) | 458 | (and (symbolp (cdr-safe elt)) (fboundp (cdr-safe elt)))) |
| 462 | (setq km (cdr elt)) | 459 | (setq km (cdr elt)) |
| 463 | (and (stringp (car elt)) (setq str (car elt)))) | 460 | (and (stringp (car elt)) (setq str (car elt)))) |
| 464 | 461 | ||
| 465 | ((if (listp (cdr-safe (cdr-safe elt))) | 462 | ((if (listp (cdr-safe (cdr-safe elt))) |
| 466 | (or (keymapp (cdr-safe (cdr-safe elt))) | 463 | (or (keymapp (cdr-safe (cdr-safe elt))) |
| 467 | (eq (car (cdr-safe (cdr-safe elt))) 'lambda)) | 464 | (eq (car (cdr-safe (cdr-safe elt))) 'lambda)) |
| 468 | (fboundp (cdr-safe (cdr-safe elt)))) | 465 | (and (symbolp (cdr-safe (cdr-safe elt))) |
| 466 | (fboundp (cdr-safe (cdr-safe elt))))) | ||
| 469 | (setq km (cddr elt)) | 467 | (setq km (cddr elt)) |
| 470 | (and (stringp (car elt)) (setq str (car elt))) | 468 | (and (stringp (car elt)) (setq str (car elt)))) |
| 471 | (and str | ||
| 472 | (stringp (cdr-safe (cadr elt))) ; keyseq cache | ||
| 473 | (setq cache (cdr (cadr elt))) | ||
| 474 | cache (setq str (concat str cache)))) | ||
| 475 | 469 | ||
| 476 | ((eq (car-safe elt) 'menu-item) | 470 | ((eq (car-safe elt) 'menu-item) |
| 477 | ;; (menu-item TITLE COMMAND KEY ...) | 471 | ;; (menu-item TITLE COMMAND KEY ...) |
| @@ -488,30 +482,34 @@ It uses the free variable `tmm-table-undef' to keep undefined keys." | |||
| 488 | (setq km (and (eval visible) km))) | 482 | (setq km (and (eval visible) km))) |
| 489 | (setq enable (plist-get plist :enable)) | 483 | (setq enable (plist-get plist :enable)) |
| 490 | (if enable | 484 | (if enable |
| 491 | (setq km (if (eval enable) km 'ignore))) | 485 | (setq km (if (eval enable) km 'ignore)))) |
| 492 | (and str | ||
| 493 | (consp (nth 3 elt)) | ||
| 494 | (stringp (cdr (nth 3 elt))) ; keyseq cache | ||
| 495 | (setq cache (cdr (nth 3 elt))) | ||
| 496 | cache | ||
| 497 | (setq str (concat str cache)))) | ||
| 498 | 486 | ||
| 499 | ((if (listp (cdr-safe (cdr-safe (cdr-safe elt)))) | 487 | ((if (listp (cdr-safe (cdr-safe (cdr-safe elt)))) |
| 500 | (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt)))) | 488 | (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt)))) |
| 501 | (eq (car (cdr-safe (cdr-safe (cdr-safe elt)))) 'lambda)) | 489 | (eq (car (cdr-safe (cdr-safe (cdr-safe elt)))) 'lambda)) |
| 502 | (fboundp (cdr-safe (cdr-safe (cdr-safe elt))))) | 490 | (and (symbolp (cdr-safe (cdr-safe (cdr-safe elt)))) |
| 491 | (fboundp (cdr-safe (cdr-safe (cdr-safe elt)))))) | ||
| 503 | ; New style of easy-menu | 492 | ; New style of easy-menu |
| 504 | (setq km (cdr (cddr elt))) | 493 | (setq km (cdr (cddr elt))) |
| 505 | (and (stringp (car elt)) (setq str (car elt))) | 494 | (and (stringp (car elt)) (setq str (car elt)))) |
| 506 | (and str | ||
| 507 | (stringp (cdr-safe (car (cddr elt)))) ; keyseq cache | ||
| 508 | (setq cache (cdr (car (cdr (cdr elt))))) | ||
| 509 | cache (setq str (concat str cache)))) | ||
| 510 | 495 | ||
| 511 | ((stringp event) ; x-popup or x-popup element | 496 | ((stringp event) ; x-popup or x-popup element |
| 512 | (if (or in-x-menu (stringp (car-safe elt))) | 497 | (if (or in-x-menu (stringp (car-safe elt))) |
| 513 | (setq str event event nil km elt) | 498 | (setq str event event nil km elt) |
| 514 | (setq str event event nil km (cons 'keymap elt)))))) | 499 | (setq str event event nil km (cons 'keymap elt))))) |
| 500 | (unless (eq km 'ignore) | ||
| 501 | (let ((binding (where-is-internal km nil t))) | ||
| 502 | (when binding | ||
| 503 | (setq binding (key-description binding)) | ||
| 504 | ;; Try to align the keybindings. | ||
| 505 | (let ((colwidth (min 30 (- (/ (window-width) 2) 10)))) | ||
| 506 | (setq str | ||
| 507 | (concat str | ||
| 508 | (make-string (max 2 (- colwidth | ||
| 509 | (string-width str) | ||
| 510 | (string-width binding))) | ||
| 511 | ?\s) | ||
| 512 | binding))))))) | ||
| 515 | (and km (stringp km) (setq str km)) | 513 | (and km (stringp km) (setq str km)) |
| 516 | ;; Verify that the command is enabled; | 514 | ;; Verify that the command is enabled; |
| 517 | ;; if not, don't mention it. | 515 | ;; if not, don't mention it. |