Mercurial > emacs
annotate lisp/tmm.el @ 18017:4c3a2b58fd72
(edebug-signal): Avoid infinite recursion.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 29 May 1997 06:32:44 +0000 |
parents | defd7a515c09 |
children | de905e8be2e0 |
rev | line source |
---|---|
13337 | 1 ;;; tmm.el --- text mode access to menu-bar |
10955 | 2 |
14733 | 3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. |
10955 | 4 |
5 ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu> | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
6 ;; Maintainer: FSF |
10955 | 7 |
10956 | 8 ;; This file is part of GNU Emacs. |
10955 | 9 |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
10955 | 24 |
14169 | 25 ;;; Commentary: |
10955 | 26 |
14169 | 27 ;; To use this package add |
10955 | 28 |
14169 | 29 ;; (autoload 'tmm-menubar 'tmm "Text mode substitute for menubar" t) |
30 ;; (global-set-key [f10] 'tmm-menubar) | |
31 ;; to your .emacs file. You can also add your own access to different | |
32 ;; menus available in Window System Emacs modeling definition after | |
33 ;; tmm-menubar. | |
10955 | 34 |
14169 | 35 ;;; Code: |
10955 | 36 |
37 (require 'electric) | |
38 | |
39 ;;; The following will be localized, added only to pacify the compiler. | |
40 (defvar tmm-short-cuts) | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
41 (defvar tmm-old-mb-map nil) |
10955 | 42 (defvar tmm-old-comp-map) |
43 (defvar tmm-c-prompt) | |
44 (defvar tmm-km-list) | |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
45 (defvar tmm-next-shortcut-digit) |
10955 | 46 (defvar tmm-table-undef) |
47 | |
12960
6db607a7b62d
Fix typo in global-map define.
Richard M. Stallman <rms@gnu.org>
parents:
12763
diff
changeset
|
48 ;;;###autoload (define-key global-map "\M-`" 'tmm-menubar) |
13480
edc4a329403e
(tmm-define-keys): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
49 ;;;###autoload (define-key global-map [f10] 'tmm-menubar) |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
50 ;;;###autoload (define-key global-map [menu-bar mouse-1] 'tmm-menubar-mouse) |
12763
b8e986069a58
Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents:
10956
diff
changeset
|
51 |
10955 | 52 ;;;###autoload |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
53 (defun tmm-menubar (&optional x-position) |
10955 | 54 "Text-mode emulation of looking and choosing from a menubar. |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
55 See the documentation for `tmm-prompt'. |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
56 X-POSITION, if non-nil, specifies a horizontal position within the menu bar; |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
57 we make that menu bar item (the one at that position) the default choice." |
10955 | 58 (interactive) |
59 (run-hooks 'menu-bar-update-hook) | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
60 ;; Obey menu-bar-final-items; put those items last. |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
61 (let ((menu-bar (tmm-get-keybind [menu-bar])) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
62 menu-bar-item) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
63 (let ((list menu-bar-final-items)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
64 (while list |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
65 (let ((item (car list))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
66 ;; ITEM is the name of an item that we want to put last. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
67 ;; Find it in MENU-BAR and move it to the end. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
68 (let ((this-one (assq item menu-bar))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
69 (setq menu-bar (append (delq this-one menu-bar) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
70 (list this-one))))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
71 (setq list (cdr list)))) |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
72 (if x-position |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
73 (let ((tail menu-bar) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
74 this-one |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
75 (column 0)) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
76 (while (and tail (< column x-position)) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
77 (setq this-one (car tail)) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
78 (if (and (consp (car tail)) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
79 (consp (cdr (car tail))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
80 (stringp (nth 1 (car tail)))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
81 (setq column (+ column |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
82 (length (nth 1 (car tail))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
83 1))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
84 (setq tail (cdr tail))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
85 (setq menu-bar-item (car this-one)))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
86 (tmm-prompt menu-bar nil menu-bar-item))) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
87 |
14120
4d4eb72a8d65
(tmm-menubar-mouse): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
14011
diff
changeset
|
88 ;;;###autoload |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
89 (defun tmm-menubar-mouse (event) |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
90 "Text-mode emulation of looking and choosing from a menubar. |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
91 This command is used when you click the mouse in the menubar |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
92 on a console which has no window system but does have a mouse. |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
93 See the documentation for `tmm-prompt'." |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
94 (interactive "e") |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
95 (tmm-menubar (car (posn-x-y (event-start event))))) |
10955 | 96 |
97 (defvar tmm-mid-prompt "==>" | |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
98 "*String to insert between shortcut and menu item. |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
99 If nil, there will be no shortcuts. It should not consist only of spaces, |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
100 or else the correct item might not be found in the `*Completions*' buffer.") |
10955 | 101 |
102 (defvar tmm-mb-map nil | |
103 "A place to store minibuffer map.") | |
104 | |
105 (defvar tmm-completion-prompt | |
106 "Press PageUp Key to reach this buffer from the minibuffer. | |
107 Alternatively, you can use Up/Down keys (or your History keys) to change | |
108 the item in the minibuffer, and press RET when you are done, or press the | |
13533
d081e1969406
(tmm-define-keys): Don't define ESC ESC.
Richard M. Stallman <rms@gnu.org>
parents:
13499
diff
changeset
|
109 marked letters to pick up your choice. Type C-g or ESC ESC ESC to cancel. |
10955 | 110 " |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
111 "*Help text to insert on the top of the completion buffer. |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
112 To save space, you can set this to nil, |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
113 in which case the standard introduction text is deleted too.") |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
114 |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
115 (defvar tmm-shortcut-style '(downcase upcase) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
116 "*What letters to use as menu shortcuts. |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
117 Must be either one of the symbols `downcase' or `upcase', |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
118 or else a list of the two in the order you prefer.") |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
119 |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
120 (defvar tmm-shortcut-words 2 |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
121 "*How many successive words to try for shortcuts, nil means all. |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
122 If you use only one of `downcase' or `upcase' for `tmm-shortcut-style', |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
123 specify nil for this variable.") |
10955 | 124 |
125 ;;;###autoload | |
13916
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
126 (defun tmm-prompt (menu &optional in-popup default-item) |
10955 | 127 "Text-mode emulation of calling the bindings in keymap. |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
128 Creates a text-mode menu of possible choices. You can access the elements |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
129 in the menu in two ways: |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
130 *) via history mechanism from minibuffer; |
10955 | 131 *) Or via completion-buffer that is automatically shown. |
132 The last alternative is currently a hack, you cannot use mouse reliably. | |
13916
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
133 |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
134 MENU is like the MENU argument to `x-popup-menu': either a |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
135 keymap or an alist of alists. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
136 DEFAULT-ITEM, if non-nil, specifies an initial default choice. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
137 Its value should be an event that has a binding in MENU." |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
138 ;; If the optional argument IN-POPUP is t, |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
139 ;; then MENU is an alist of elements of the form (STRING . VALUE). |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
140 ;; That is used for recursive calls only. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
141 (let ((gl-str "Menu bar") ;; The menu bar itself is not a menu keymap |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
142 ; so it doesn't have a name. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
143 tmm-km-list out history history-len tmm-table-undef tmm-c-prompt |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
144 tmm-old-mb-map tmm-old-comp-map tmm-short-cuts |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
145 chosen-string choice |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
146 (not-menu (not (keymapp menu)))) |
10955 | 147 (run-hooks 'activate-menubar-hook) |
13916
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
148 ;; Compute tmm-km-list from MENU. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
149 ;; tmm-km-list is an alist of (STRING . MEANING). |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
150 ;; It has no other elements. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
151 ;; The order of elements in tmm-km-list is the order of the menu bar. |
10955 | 152 (mapcar (function (lambda (elt) |
153 (if (stringp elt) | |
154 (setq gl-str elt) | |
13916
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
155 (and (listp elt) (tmm-get-keymap elt not-menu))))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
156 menu) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
157 ;; Choose an element of tmm-km-list; put it in choice. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
158 (if (and not-menu (= 1 (length tmm-km-list))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
159 ;; If this is the top-level of an x-popup-menu menu, |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
160 ;; and there is just one pane, choose that one silently. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
161 ;; This way we only ask the user one question, |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
162 ;; for which element of that pane. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
163 (setq choice (cdr (car tmm-km-list))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
164 (and tmm-km-list |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
165 (let ((index-of-default 0)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
166 (if tmm-mid-prompt |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
167 (setq tmm-km-list (tmm-add-shortcuts tmm-km-list)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
168 t) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
169 ;; Find the default item's index within the menu bar. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
170 ;; We use this to decide the initial minibuffer contents |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
171 ;; and initial history position. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
172 (if default-item |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
173 (let ((tail menu)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
174 (while (and tail |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
175 (not (eq (car-safe (car tail)) default-item))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
176 ;; Be careful to count only the elements of MENU |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
177 ;; that actually constitute menu bar items. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
178 (if (and (consp (car tail)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
179 (stringp (car-safe (cdr (car tail))))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
180 (setq index-of-default (1+ index-of-default))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
181 (setq tail (cdr tail))))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
182 (setq history (reverse (mapcar 'car tmm-km-list))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
183 (setq history-len (length history)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
184 (setq history (append history history history history)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
185 (setq tmm-c-prompt (nth (- history-len 1 index-of-default) history)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
186 (add-hook 'minibuffer-setup-hook 'tmm-add-prompt) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
187 (unwind-protect |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
188 (setq out |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
189 (completing-read |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
190 (concat gl-str " (up/down to change, PgUp to menu): ") |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
191 tmm-km-list nil t nil |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
192 (cons 'history (- (* 2 history-len) index-of-default)))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
193 (save-excursion |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
194 (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
195 (if (get-buffer "*Completions*") |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
196 (progn |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
197 (set-buffer "*Completions*") |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
198 (use-local-map tmm-old-comp-map) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
199 (bury-buffer (current-buffer))))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
200 ))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
201 (setq choice (cdr (assoc out tmm-km-list))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
202 (and (null choice) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
203 (> (length out) (length tmm-c-prompt)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
204 (string= (substring out 0 (length tmm-c-prompt)) tmm-c-prompt) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
205 (setq out (substring out (length tmm-c-prompt)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
206 choice (cdr (assoc out tmm-km-list)))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
207 (and (null choice) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
208 (setq out (try-completion out tmm-km-list) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
209 choice (cdr (assoc out tmm-km-list))))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
210 ;; CHOICE is now (STRING . MEANING). Separate the two parts. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
211 (setq chosen-string (car choice)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
212 (setq choice (cdr choice)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
213 (cond (in-popup |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
214 ;; We just did the inner level of a -popup menu. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
215 choice) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
216 ;; We just did the outer level. Do the inner level now. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
217 (not-menu (tmm-prompt choice t)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
218 ;; We just handled a menu keymap and found another keymap. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
219 ((keymapp choice) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
220 (if (symbolp choice) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
221 (setq choice (indirect-function choice))) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
222 (condition-case nil |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
223 (require 'mouse) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
224 (error nil)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
225 (condition-case nil |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
226 (x-popup-menu nil choice) ; Get the shortcuts |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
227 (error nil)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
228 (tmm-prompt choice)) |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
229 ;; We just handled a menu keymap and found a command. |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
230 (choice |
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
231 (if chosen-string |
14282
63fbb2aeb1f2
(tmm-prompt): Set last-command-event before calling the
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
232 (progn |
63fbb2aeb1f2
(tmm-prompt): Set last-command-event before calling the
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
233 (setq last-command-event chosen-string) |
63fbb2aeb1f2
(tmm-prompt): Set last-command-event before calling the
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
234 (call-interactively choice)) |
13916
00065bf711b8
(tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents:
13915
diff
changeset
|
235 choice))))) |
10955 | 236 |
237 (defun tmm-add-shortcuts (list) | |
238 "Adds shortcuts to cars of elements of the list. | |
239 Takes a list of lists with a string as car, returns list with | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
240 shortcuts added to these cars. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
241 Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
242 (let ((tmm-next-shortcut-digit ?0)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
243 (mapcar 'tmm-add-one-shortcut (reverse list)))) |
10955 | 244 |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
245 (defsubst tmm-add-one-shortcut (elt) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
246 ;; uses the free vars tmm-next-shortcut-digit and tmm-short-cuts |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
247 (let* ((str (car elt)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
248 (paren (string-match "(" str)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
249 (pos 0) (word 0) char) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
250 (catch 'done ; ??? is this slow? |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
251 (while (and (or (not tmm-shortcut-words) ; no limit on words |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
252 (< word tmm-shortcut-words)) ; try n words |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
253 (setq pos (string-match "\\w+" str pos)) ; get next word |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
254 (not (and paren (> pos paren)))) ; don't go past "(binding.." |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
255 (if (or (= pos 0) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
256 (/= (aref str (1- pos)) ?.)) ; avoid file extensions |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
257 (let ((shortcut-style |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
258 (if (listp tmm-shortcut-style) ; convert to list |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
259 tmm-shortcut-style |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
260 (list tmm-shortcut-style)))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
261 (while shortcut-style ; try upcase and downcase variants |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
262 (setq char (funcall (car shortcut-style) (aref str pos))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
263 (if (not (memq char tmm-short-cuts)) (throw 'done char)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
264 (setq shortcut-style (cdr shortcut-style))))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
265 (setq word (1+ word)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
266 (setq pos (match-end 0))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
267 (while (<= tmm-next-shortcut-digit ?9) ; no letter shortcut, pick a digit |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
268 (setq char tmm-next-shortcut-digit) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
269 (setq tmm-next-shortcut-digit (1+ tmm-next-shortcut-digit)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
270 (if (not (memq char tmm-short-cuts)) (throw 'done char))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
271 (setq char nil)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
272 (if char (setq tmm-short-cuts (cons char tmm-short-cuts))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
273 (cons (concat (if char (concat (char-to-string char) tmm-mid-prompt) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
274 ;; keep them lined up in columns |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
275 (make-string (1+ (length tmm-mid-prompt)) ?\ )) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
276 str) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
277 (cdr elt)))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
278 |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
279 ;; This returns the old map. |
14902
6dc4dee167eb
(tmm-define-keys): New arg MINIBUFFER.
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
280 (defun tmm-define-keys (minibuffer) |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
281 (let ((map (make-sparse-keymap))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
282 (suppress-keymap map t) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
283 (mapcar |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
284 (function |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
285 (lambda (c) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
286 (if (listp tmm-shortcut-style) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
287 (define-key map (char-to-string c) 'tmm-shortcut) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
288 ;; only one kind of letters are shortcuts, so map both upcase and |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
289 ;; downcase input to the same |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
290 (define-key map (char-to-string (downcase c)) 'tmm-shortcut) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
291 (define-key map (char-to-string (upcase c)) 'tmm-shortcut)))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
292 tmm-short-cuts) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
293 (if minibuffer |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
294 (progn |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
295 (define-key map [pageup] 'tmm-goto-completions) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
296 (define-key map [prior] 'tmm-goto-completions) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
297 (define-key map "\ev" 'tmm-goto-completions) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
298 (define-key map "\C-n" 'next-history-element) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
299 (define-key map "\C-p" 'previous-history-element))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
300 (prog1 (current-local-map) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
301 (use-local-map (append map (current-local-map)))))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
302 |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
303 (defun tmm-completion-delete-prompt () |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
304 (set-buffer standard-output) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
305 (goto-char 1) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
306 (delete-region 1 (search-forward "Possible completions are:\n"))) |
13480
edc4a329403e
(tmm-define-keys): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
307 |
10955 | 308 (defun tmm-add-prompt () |
309 (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) | |
12763
b8e986069a58
Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents:
10956
diff
changeset
|
310 (make-local-hook 'minibuffer-exit-hook) |
b8e986069a58
Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents:
10956
diff
changeset
|
311 (add-hook 'minibuffer-exit-hook 'tmm-delete-map nil t) |
13480
edc4a329403e
(tmm-define-keys): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
312 (let ((win (selected-window))) |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
313 (setq tmm-old-mb-map (tmm-define-keys t)) |
10955 | 314 ;; Get window and hide it for electric mode to get correct size |
315 (save-window-excursion | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
316 (let ((completions |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
317 (mapcar 'car minibuffer-completion-table))) |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
318 (or tmm-completion-prompt |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
319 (add-hook 'completion-setup-hook |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
320 'tmm-completion-delete-prompt 'append)) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
321 (with-output-to-temp-buffer "*Completions*" |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
322 (display-completion-list completions)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
323 (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
324 (if tmm-completion-prompt |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
325 (progn |
10955 | 326 (set-buffer "*Completions*") |
327 (goto-char 1) | |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
328 (insert tmm-completion-prompt))) |
10955 | 329 ) |
330 (save-excursion | |
331 (other-window 1) ; Electric-pop-up-window does | |
332 ; not work in minibuffer | |
333 (set-buffer (window-buffer (Electric-pop-up-window "*Completions*"))) | |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
334 |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
335 (setq tmm-old-comp-map (tmm-define-keys nil)) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
336 |
10955 | 337 (select-window win) ; Cannot use |
338 ; save-window-excursion, since | |
339 ; it restores the size | |
340 ) | |
341 (insert tmm-c-prompt))) | |
342 | |
343 (defun tmm-delete-map () | |
12763
b8e986069a58
Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents:
10956
diff
changeset
|
344 (remove-hook 'minibuffer-exit-hook 'tmm-delete-map t) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
345 (if tmm-old-mb-map |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
346 (use-local-map tmm-old-mb-map))) |
10955 | 347 |
348 (defun tmm-shortcut () | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
349 "Choose the shortcut that the user typed." |
10955 | 350 (interactive) |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
351 (let ((c last-command-char) s) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
352 (if (symbolp tmm-shortcut-style) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
353 (setq c (funcall tmm-shortcut-style c))) |
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
354 (if (memq c tmm-short-cuts) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
355 (if (equal (buffer-name) "*Completions*") |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
356 (progn |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
357 (beginning-of-buffer) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
358 (re-search-forward |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
359 (concat "\\(^\\|[ \t]\\)" (char-to-string c) tmm-mid-prompt)) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
360 (choose-completion)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
361 (erase-buffer) ; In minibuffer |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
362 (mapcar (lambda (elt) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
363 (if (string= |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
364 (substring (car elt) 0 |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
365 (min (1+ (length tmm-mid-prompt)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
366 (length (car elt)))) |
16040
74fc923ff6d5
(tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents:
15564
diff
changeset
|
367 (concat (char-to-string c) tmm-mid-prompt)) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
368 (setq s (car elt)))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
369 tmm-km-list) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
370 (insert s) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
371 (exit-minibuffer))))) |
10955 | 372 |
373 (defun tmm-goto-completions () | |
374 (interactive) | |
375 (setq tmm-c-prompt (buffer-string)) | |
376 (erase-buffer) | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
377 (switch-to-buffer-other-window "*Completions*") |
10955 | 378 (search-forward tmm-c-prompt) |
379 (search-backward tmm-c-prompt)) | |
380 | |
381 (defun tmm-get-keymap (elt &optional in-x-menu) | |
382 "Prepends (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'. | |
383 The values are deduced from the argument ELT, that should be an | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
384 element of keymap, an `x-popup-menu' argument, or an element of |
10955 | 385 `x-popup-menu' argument (when IN-X-MENU is not-nil). |
13915
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
386 This function adds the element only if it is not already present. |
1319e4b9aa6c
(tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents:
13581
diff
changeset
|
387 It uses the free variable `tmm-table-undef' to keep undefined keys." |
10955 | 388 (let (km str cache (event (car elt))) |
389 (setq elt (cdr elt)) | |
390 (if (eq elt 'undefined) | |
391 (setq tmm-table-undef (cons (cons event nil) tmm-table-undef)) | |
392 (or | |
393 (assoc event tmm-table-undef) | |
394 (and (if (listp elt) | |
16922
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
395 (or (keymapp elt) (eq (car elt) 'lambda)) |
10955 | 396 (fboundp elt)) |
397 (setq km elt)) | |
398 (and (if (listp (cdr-safe elt)) | |
16922
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
399 (or (keymapp (cdr-safe elt)) |
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
400 (eq (car (cdr-safe elt)) 'lambda)) |
10955 | 401 (fboundp (cdr-safe elt))) |
402 (setq km (cdr elt)) | |
403 (and (stringp (car elt)) (setq str (car elt)))) | |
404 (and (if (listp (cdr-safe (cdr-safe elt))) | |
16922
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
405 (or (keymapp (cdr-safe (cdr-safe elt))) |
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
406 (eq (car (cdr-safe (cdr-safe elt))) 'lambda)) |
10955 | 407 (fboundp (cdr-safe (cdr-safe elt)))) |
408 (setq km (cdr (cdr elt))) | |
409 (and (stringp (car elt)) (setq str (car elt))) | |
410 (or (and str | |
411 (stringp (cdr (car (cdr elt)))) ; keyseq cache | |
412 (setq cache (cdr (car (cdr elt)))) | |
413 cache (setq str (concat str cache))) str)) | |
414 (and (if (listp (cdr-safe (cdr-safe (cdr-safe elt)))) | |
16922
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
415 (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt)))) |
defd7a515c09
(tmm-get-keymap): Recognize explicit lambda expressions as valid.
Richard M. Stallman <rms@gnu.org>
parents:
16040
diff
changeset
|
416 (eq (car (cdr-safe (cdr-safe (cdr-safe elt)))) 'lambda)) |
10955 | 417 (fboundp (cdr-safe (cdr-safe (cdr-safe elt))))) |
418 ; New style of easy-menu | |
419 (setq km (cdr (cdr (cdr elt)))) | |
420 (and (stringp (car elt)) (setq str (car elt))) | |
421 (or (and str | |
422 (stringp (cdr (car (cdr (cdr elt))))) ; keyseq cache | |
423 (setq cache (cdr (car (cdr (cdr elt))))) | |
424 cache (setq str (concat str cache))) | |
425 str)) | |
426 (and (stringp event) ; x-popup or x-popup element | |
427 (if (or in-x-menu (stringp (car-safe elt))) | |
428 (setq str event event nil km elt) | |
429 (setq str event event nil km (cons 'keymap elt)) | |
430 ))) | |
431 (and km (stringp km) (setq str km)) | |
432 (and km str | |
433 (or (assoc str tmm-km-list) | |
434 (setq tmm-km-list | |
435 (cons (cons str (cons event km)) tmm-km-list))) | |
436 )))) | |
437 | |
438 (defun tmm-get-keybind (keyseq) | |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
439 "Return the current binding of KEYSEQ, merging prefix definitions. |
14011 | 440 If KEYSEQ is a prefix key that has local and global bindings, |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
441 we merge them into a single keymap which shows the proper order of the menu. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
442 However, for the menu bar itself, the value does not take account |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
443 of `menu-bar-final-items'." |
10955 | 444 (let (allbind bind) |
13334
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
445 (setq bind (key-binding keyseq)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
446 ;; If KEYSEQ is a prefix key, then BIND is either nil |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
447 ;; or a symbol defined as a keymap (which satisfies keymapp). |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
448 (if (keymapp bind) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
449 (setq bind nil)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
450 ;; If we have a non-keymap definition, return that. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
451 (or bind |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
452 (progn |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
453 ;; Otherwise, it is a prefix, so make a list of the subcommands. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
454 ;; Make a list of all the bindings in all the keymaps. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
455 (setq allbind (mapcar 'cdr (minor-mode-key-binding keyseq))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
456 (setq allbind (cons (local-key-binding keyseq) allbind)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
457 (setq allbind (cons (global-key-binding keyseq) allbind)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
458 ;; Merge all the elements of ALLBIND into one keymap. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
459 (mapcar (lambda (in) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
460 (if (and (symbolp in) (keymapp in)) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
461 (setq in (symbol-function in))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
462 (and in (keymapp in) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
463 (if (keymapp bind) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
464 (setq bind (nconc bind (copy-sequence (cdr in)))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
465 (setq bind (copy-sequence in))))) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
466 allbind) |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
467 ;; Return that keymap. |
c55f17d3931f
(tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents:
12960
diff
changeset
|
468 bind)))) |
10955 | 469 |
470 (add-hook 'calendar-load-hook (lambda () (require 'cal-menu))) | |
471 | |
472 (provide 'tmm) | |
473 | |
474 ;;; tmm.el ends here |