Mercurial > emacs
diff lisp/tmm.el @ 83561:dc002877ce12
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-674
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-675
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-676
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-677
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-678
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-679
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-680
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-681
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-682
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-683
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-684
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-685
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-686
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-687
Release ERC 5.2.
* emacs@sv.gnu.org/emacs--devo--0--patch-688
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-689
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-690
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-691
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-692
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-693
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-694
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-695
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-696
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-697
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-698
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-699
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-700
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-701
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-209
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-210
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-211
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-212
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-213
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-214
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-215
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-601
author | Karoly Lorentey <karoly@lorentey.hu> |
---|---|
date | Sun, 22 Apr 2007 12:42:47 +0000 |
parents | b8d9a391daf3 4588da3832c6 |
children | 65663fcd2caa |
line wrap: on
line diff
--- a/lisp/tmm.el Sun Apr 22 12:12:29 2007 +0000 +++ b/lisp/tmm.el Sun Apr 22 12:42:47 2007 +0000 @@ -41,7 +41,7 @@ (defvar tmm-short-cuts) (defvar tmm-old-mb-map nil) (defvar tmm-old-comp-map) -(defvar tmm-c-prompt) +(defvar tmm-c-prompt nil) (defvar tmm-km-list) (defvar tmm-next-shortcut-digit) (defvar tmm-table-undef) @@ -70,17 +70,22 @@ (list this-one))))) (setq list (cdr list)))) (if x-position - (let ((tail menu-bar) - this-one - (column 0)) - (while (and tail (< column x-position)) + (let ((tail menu-bar) (column 0) + this-one name visible) + (while (and tail (<= column x-position)) (setq this-one (car tail)) - (if (and (consp (car tail)) - (consp (cdr (car tail))) - (stringp (nth 1 (car tail)))) - (setq column (+ column - (length (nth 1 (car tail))) - 1))) + (if (and (consp this-one) + (consp (cdr this-one)) + (setq name ;simple menu + (cond ((stringp (nth 1 this-one)) + (nth 1 this-one)) + ;extended menu + ((stringp (nth 2 this-one)) + (setq visible (plist-get + (nthcdr 4 this-one) :visible)) + (unless (and visible (not (eval visible))) + (nth 2 this-one)))))) + (setq column (+ column (length name) 1))) (setq tail (cdr tail))) (setq menu-bar-item (car this-one)))) (tmm-prompt menu-bar nil menu-bar-item))) @@ -187,14 +192,20 @@ ;; We use this to decide the initial minibuffer contents ;; and initial history position. (if default-item - (let ((tail menu)) + (let ((tail menu) visible) (while (and tail (not (eq (car-safe (car tail)) default-item))) ;; Be careful to count only the elements of MENU ;; that actually constitute menu bar items. (if (and (consp (car tail)) (or (stringp (car-safe (cdr (car tail)))) - (eq (car-safe (cdr (car tail))) 'menu-item))) + (and + (eq (car-safe (cdr (car tail))) 'menu-item) + (progn + (setq visible + (plist-get + (nthcdr 4 (car tail)) :visible)) + (or (not visible) (eval visible)))))) (setq index-of-default (1+ index-of-default))) (setq tail (cdr tail))))) (let ((prompt (concat "^." (regexp-quote tmm-mid-prompt)))) @@ -209,21 +220,24 @@ (setq history (append history history history history)) (setq tmm-c-prompt (nth (- history-len 1 index-of-default) history)) (add-hook 'minibuffer-setup-hook 'tmm-add-prompt) - (save-excursion - (unwind-protect - (setq out - (completing-read - (concat gl-str " (up/down to change, PgUp to menu): ") - tmm-km-list nil t nil - (cons 'history (- (* 2 history-len) index-of-default)))) - (save-excursion - (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) - (if (get-buffer "*Completions*") - (progn - (set-buffer "*Completions*") - (use-local-map tmm-old-comp-map) - (bury-buffer (current-buffer))))) - )))) + (if default-item + (setq out (car (nth index-of-default tmm-km-list))) + (save-excursion + (unwind-protect + (setq out + (completing-read + (concat gl-str + " (up/down to change, PgUp to menu): ") + tmm-km-list nil t nil + (cons 'history + (- (* 2 history-len) index-of-default)))) + (save-excursion + (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) + (if (get-buffer "*Completions*") + (progn + (set-buffer "*Completions*") + (use-local-map tmm-old-comp-map) + (bury-buffer (current-buffer)))))))))) (setq choice (cdr (assoc out tmm-km-list))) (and (null choice) (> (length out) (length tmm-c-prompt)) @@ -513,7 +527,7 @@ we merge them into a single keymap which shows the proper order of the menu. However, for the menu bar itself, the value does not take account of `menu-bar-final-items'." - (let (allbind bind) + (let (allbind bind minorbind localbind globalbind) (setq bind (key-binding keyseq)) ;; If KEYSEQ is a prefix key, then BIND is either nil ;; or a symbol defined as a keymap (which satisfies keymapp). @@ -524,9 +538,21 @@ (progn ;; Otherwise, it is a prefix, so make a list of the subcommands. ;; Make a list of all the bindings in all the keymaps. - (setq allbind (mapcar 'cdr (minor-mode-key-binding keyseq))) - (setq allbind (cons (local-key-binding keyseq) allbind)) - (setq allbind (cons (global-key-binding keyseq) allbind)) + (setq minorbind (mapcar 'cdr (minor-mode-key-binding keyseq))) + (setq localbind (local-key-binding keyseq)) + (setq globalbind (copy-sequence (cdr (global-key-binding keyseq)))) + + ;; If items have been redefined/undefined locally, remove them from + ;; the global list. + (dolist (minor minorbind) + (dolist (item (cdr minor)) + (setq globalbind (assq-delete-all (car-safe item) globalbind)))) + (dolist (item (cdr localbind)) + (setq globalbind (assq-delete-all (car-safe item) globalbind))) + + (setq globalbind (cons 'keymap globalbind)) + (setq allbind (cons globalbind (cons localbind minorbind))) + ;; Merge all the elements of ALLBIND into one keymap. (mapc (lambda (in) (if (and (symbolp in) (keymapp in))