tmm.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. ;;; tmm.el --- text mode access to menu-bar -*- lexical-binding: t -*-
  2. ;; Copyright (C) 1994-1996, 2000-2017 Free Software Foundation, Inc.
  3. ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu>
  4. ;; Maintainer: emacs-devel@gnu.org
  5. ;; Keywords: convenience
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; This package provides text mode access to the menu bar.
  19. ;;; Code:
  20. (require 'electric)
  21. (defgroup tmm nil
  22. "Text mode access to menu-bar."
  23. :prefix "tmm-"
  24. :group 'menu)
  25. ;;; The following will be localized, added only to pacify the compiler.
  26. (defvar tmm-short-cuts)
  27. (defvar tmm-old-mb-map nil)
  28. (defvar tmm-c-prompt nil)
  29. (defvar tmm-km-list)
  30. (defvar tmm-next-shortcut-digit)
  31. (defvar tmm-table-undef)
  32. ;;;###autoload (define-key global-map "\M-`" 'tmm-menubar)
  33. ;;;###autoload (define-key global-map [menu-bar mouse-1] 'tmm-menubar-mouse)
  34. ;;;###autoload
  35. (defun tmm-menubar (&optional x-position)
  36. "Text-mode emulation of looking and choosing from a menubar.
  37. See the documentation for `tmm-prompt'.
  38. X-POSITION, if non-nil, specifies a horizontal position within the menu bar;
  39. we make that menu bar item (the one at that position) the default choice.
  40. Note that \\[menu-bar-open] by default drops down TTY menus; if you want it
  41. to invoke `tmm-menubar' instead, customize the variable
  42. `tty-menu-open-use-tmm' to a non-nil value."
  43. (interactive)
  44. (run-hooks 'menu-bar-update-hook)
  45. ;; Obey menu-bar-final-items; put those items last.
  46. (let ((menu-bar '())
  47. (menu-end '())
  48. menu-bar-item)
  49. (map-keymap
  50. (lambda (key binding)
  51. (push (cons key binding)
  52. ;; If KEY is the name of an item that we want to put last,
  53. ;; move it to the end.
  54. (if (memq key menu-bar-final-items)
  55. menu-end
  56. menu-bar)))
  57. (tmm-get-keybind [menu-bar]))
  58. (setq menu-bar `(keymap ,@(nreverse menu-bar) ,@(nreverse menu-end)))
  59. (if x-position
  60. (let ((column 0)
  61. prev-key)
  62. (catch 'done
  63. (map-keymap
  64. (lambda (key binding)
  65. (when (> column x-position)
  66. (setq menu-bar-item prev-key)
  67. (throw 'done nil))
  68. (setq prev-key key)
  69. (pcase binding
  70. ((or `(,(and (pred stringp) name) . ,_) ;Simple menu item.
  71. `(menu-item ,name ,_cmd ;Extended menu item.
  72. . ,(and props
  73. (guard (let ((visible
  74. (plist-get props :visible)))
  75. (or (null visible)
  76. (eval visible)))))))
  77. (setq column (+ column (length name) 1)))))
  78. menu-bar))))
  79. (tmm-prompt menu-bar nil menu-bar-item)))
  80. ;;;###autoload
  81. (defun tmm-menubar-mouse (event)
  82. "Text-mode emulation of looking and choosing from a menubar.
  83. This command is used when you click the mouse in the menubar
  84. on a console which has no window system but does have a mouse.
  85. See the documentation for `tmm-prompt'."
  86. (interactive "e")
  87. (tmm-menubar (car (posn-x-y (event-start event)))))
  88. (defcustom tmm-mid-prompt "==>"
  89. "String to insert between shortcut and menu item.
  90. If nil, there will be no shortcuts. It should not consist only of spaces,
  91. or else the correct item might not be found in the `*Completions*' buffer."
  92. :type 'string
  93. :group 'tmm)
  94. (defvar tmm-mb-map nil
  95. "A place to store minibuffer map.")
  96. (defcustom tmm-completion-prompt
  97. "Press PageUp key to reach this buffer from the minibuffer.
  98. Alternatively, you can use Up/Down keys (or your History keys) to change
  99. the item in the minibuffer, and press RET when you are done, or press the
  100. marked letters to pick up your choice. Type C-g or ESC ESC ESC to cancel.
  101. "
  102. "Help text to insert on the top of the completion buffer.
  103. To save space, you can set this to nil,
  104. in which case the standard introduction text is deleted too."
  105. :type '(choice string (const nil))
  106. :group 'tmm)
  107. (defcustom tmm-shortcut-style '(downcase upcase)
  108. "What letters to use as menu shortcuts.
  109. Must be either one of the symbols `downcase' or `upcase',
  110. or else a list of the two in the order you prefer."
  111. :type '(choice (const downcase)
  112. (const upcase)
  113. (repeat (choice (const downcase) (const upcase))))
  114. :group 'tmm)
  115. (defcustom tmm-shortcut-words 2
  116. "How many successive words to try for shortcuts, nil means all.
  117. If you use only one of `downcase' or `upcase' for `tmm-shortcut-style',
  118. specify nil for this variable."
  119. :type '(choice integer (const nil))
  120. :group 'tmm)
  121. (defface tmm-inactive
  122. '((t :inherit shadow))
  123. "Face used for inactive menu items."
  124. :group 'tmm)
  125. (defun tmm--completion-table (items)
  126. (lambda (string pred action)
  127. (if (eq action 'metadata)
  128. '(metadata (display-sort-function . identity))
  129. (complete-with-action action items string pred))))
  130. (defvar tmm--history nil)
  131. ;;;###autoload
  132. (defun tmm-prompt (menu &optional in-popup default-item)
  133. "Text-mode emulation of calling the bindings in keymap.
  134. Creates a text-mode menu of possible choices. You can access the elements
  135. in the menu in two ways:
  136. *) via history mechanism from minibuffer;
  137. *) Or via completion-buffer that is automatically shown.
  138. The last alternative is currently a hack, you cannot use mouse reliably.
  139. MENU is like the MENU argument to `x-popup-menu': either a
  140. keymap or an alist of alists.
  141. DEFAULT-ITEM, if non-nil, specifies an initial default choice.
  142. Its value should be an event that has a binding in MENU."
  143. ;; If the optional argument IN-POPUP is t,
  144. ;; then MENU is an alist of elements of the form (STRING . VALUE).
  145. ;; That is used for recursive calls only.
  146. (let ((gl-str "Menu bar") ;; The menu bar itself is not a menu keymap
  147. ; so it doesn't have a name.
  148. tmm-km-list out history-len tmm-table-undef tmm-c-prompt
  149. tmm-old-mb-map tmm-short-cuts
  150. chosen-string choice
  151. (not-menu (not (keymapp menu))))
  152. (run-hooks 'activate-menubar-hook)
  153. ;; Compute tmm-km-list from MENU.
  154. ;; tmm-km-list is an alist of (STRING . MEANING).
  155. ;; It has no other elements.
  156. ;; The order of elements in tmm-km-list is the order of the menu bar.
  157. (if (not not-menu)
  158. (map-keymap (lambda (k v) (tmm-get-keymap (cons k v))) menu)
  159. (dolist (elt menu)
  160. (cond
  161. ((stringp elt) (setq gl-str elt))
  162. ((listp elt) (tmm-get-keymap elt not-menu))
  163. ((vectorp elt)
  164. (dotimes (i (length elt))
  165. (tmm-get-keymap (cons i (aref elt i)) not-menu))))))
  166. ;; Choose an element of tmm-km-list; put it in choice.
  167. (if (and not-menu (= 1 (length tmm-km-list)))
  168. ;; If this is the top-level of an x-popup-menu menu,
  169. ;; and there is just one pane, choose that one silently.
  170. ;; This way we only ask the user one question,
  171. ;; for which element of that pane.
  172. (setq choice (cdr (car tmm-km-list)))
  173. (unless tmm-km-list
  174. (error "Empty menu reached"))
  175. (and tmm-km-list
  176. (let ((index-of-default 0))
  177. (if tmm-mid-prompt
  178. (setq tmm-km-list (tmm-add-shortcuts tmm-km-list))
  179. t)
  180. ;; Find the default item's index within the menu bar.
  181. ;; We use this to decide the initial minibuffer contents
  182. ;; and initial history position.
  183. (if default-item
  184. (let ((tail menu) visible)
  185. (while (and tail
  186. (not (eq (car-safe (car tail)) default-item)))
  187. ;; Be careful to count only the elements of MENU
  188. ;; that actually constitute menu bar items.
  189. (if (and (consp (car tail))
  190. (or (stringp (car-safe (cdr (car tail))))
  191. (and
  192. (eq (car-safe (cdr (car tail))) 'menu-item)
  193. (progn
  194. (setq visible
  195. (plist-get
  196. (nthcdr 4 (car tail)) :visible))
  197. (or (not visible) (eval visible))))))
  198. (setq index-of-default (1+ index-of-default)))
  199. (setq tail (cdr tail)))))
  200. (let ((prompt (concat "^." (regexp-quote tmm-mid-prompt))))
  201. (setq tmm--history
  202. (reverse (delq nil
  203. (mapcar
  204. (lambda (elt)
  205. (if (string-match prompt (car elt))
  206. (car elt)))
  207. tmm-km-list)))))
  208. (setq history-len (length tmm--history))
  209. (setq tmm--history (append tmm--history tmm--history
  210. tmm--history tmm--history))
  211. (setq tmm-c-prompt (nth (- history-len 1 index-of-default)
  212. tmm--history))
  213. (setq out
  214. (if default-item
  215. (car (nth index-of-default tmm-km-list))
  216. (minibuffer-with-setup-hook #'tmm-add-prompt
  217. ;; tmm-km-list is reversed, because history
  218. ;; needs it in LIFO order. But completion
  219. ;; needs it in non-reverse order, so that the
  220. ;; menu items are displayed as completion
  221. ;; candidates in the order they are shown on
  222. ;; the menu bar. So pass completing-read the
  223. ;; reversed copy of the list.
  224. (completing-read-default
  225. (concat gl-str
  226. " (up/down to change, PgUp to menu): ")
  227. (tmm--completion-table (reverse tmm-km-list)) nil t nil
  228. (cons 'tmm--history
  229. (- (* 2 history-len) index-of-default))))))))
  230. (setq choice (cdr (assoc out tmm-km-list)))
  231. (and (null choice)
  232. (string-prefix-p tmm-c-prompt out)
  233. (setq out (substring out (length tmm-c-prompt))
  234. choice (cdr (assoc out tmm-km-list))))
  235. (and (null choice) out
  236. (setq out (try-completion out tmm-km-list)
  237. choice (cdr (assoc out tmm-km-list)))))
  238. ;; CHOICE is now (STRING . MEANING). Separate the two parts.
  239. (setq chosen-string (car choice))
  240. (setq choice (cdr choice))
  241. (cond (in-popup
  242. ;; We just did the inner level of a -popup menu.
  243. choice)
  244. ;; We just did the outer level. Do the inner level now.
  245. (not-menu (tmm-prompt choice t))
  246. ;; We just handled a menu keymap and found another keymap.
  247. ((keymapp choice)
  248. (if (symbolp choice)
  249. (setq choice (indirect-function choice)))
  250. (condition-case nil
  251. (require 'mouse)
  252. (error nil))
  253. (tmm-prompt choice))
  254. ;; We just handled a menu keymap and found a command.
  255. (choice
  256. (if chosen-string
  257. (progn
  258. (setq last-command-event chosen-string)
  259. (call-interactively choice))
  260. choice)))))
  261. (defun tmm-add-shortcuts (list)
  262. "Add shortcuts to cars of elements of the list.
  263. Takes a list of lists with a string as car, returns list with
  264. shortcuts added to these cars.
  265. Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
  266. (let ((tmm-next-shortcut-digit ?0))
  267. (mapcar 'tmm-add-one-shortcut (reverse list))))
  268. (defsubst tmm-add-one-shortcut (elt)
  269. ;; uses the free vars tmm-next-shortcut-digit and tmm-short-cuts
  270. (cond
  271. ((eq (cddr elt) 'ignore)
  272. (cons (concat " " (make-string (length tmm-mid-prompt) ?\-)
  273. (car elt))
  274. (cdr elt)))
  275. (t
  276. (let* ((str (car elt))
  277. (paren (string-match "(" str))
  278. (pos 0) (word 0) char)
  279. (catch 'done ; ??? is this slow?
  280. (while (and (or (not tmm-shortcut-words) ; no limit on words
  281. (< word tmm-shortcut-words)) ; try n words
  282. (setq pos (string-match "\\w+" str pos)) ; get next word
  283. (not (and paren (> pos paren)))) ; don't go past "(binding.."
  284. (if (or (= pos 0)
  285. (/= (aref str (1- pos)) ?.)) ; avoid file extensions
  286. (let ((shortcut-style
  287. (if (listp tmm-shortcut-style) ; convert to list
  288. tmm-shortcut-style
  289. (list tmm-shortcut-style))))
  290. (while shortcut-style ; try upcase and downcase variants
  291. (setq char (funcall (car shortcut-style) (aref str pos)))
  292. (if (not (memq char tmm-short-cuts)) (throw 'done char))
  293. (setq shortcut-style (cdr shortcut-style)))))
  294. (setq word (1+ word))
  295. (setq pos (match-end 0)))
  296. (while (<= tmm-next-shortcut-digit ?9) ; no letter shortcut, pick a digit
  297. (setq char tmm-next-shortcut-digit)
  298. (setq tmm-next-shortcut-digit (1+ tmm-next-shortcut-digit))
  299. (if (not (memq char tmm-short-cuts)) (throw 'done char)))
  300. (setq char nil))
  301. (if char (setq tmm-short-cuts (cons char tmm-short-cuts)))
  302. (cons (concat (if char (concat (char-to-string char) tmm-mid-prompt)
  303. ;; keep them lined up in columns
  304. (make-string (1+ (length tmm-mid-prompt)) ?\s))
  305. str)
  306. (cdr elt))))))
  307. ;; This returns the old map.
  308. (defun tmm-define-keys (minibuffer)
  309. (let ((map (make-sparse-keymap)))
  310. (suppress-keymap map t)
  311. (dolist (c tmm-short-cuts)
  312. (if (listp tmm-shortcut-style)
  313. (define-key map (char-to-string c) 'tmm-shortcut)
  314. ;; only one kind of letters are shortcuts, so map both upcase and
  315. ;; downcase input to the same
  316. (define-key map (char-to-string (downcase c)) 'tmm-shortcut)
  317. (define-key map (char-to-string (upcase c)) 'tmm-shortcut)))
  318. (if minibuffer
  319. (progn
  320. (define-key map [pageup] 'tmm-goto-completions)
  321. (define-key map [prior] 'tmm-goto-completions)
  322. (define-key map "\ev" 'tmm-goto-completions)
  323. (define-key map "\C-n" 'next-history-element)
  324. (define-key map "\C-p" 'previous-history-element)))
  325. (prog1 (current-local-map)
  326. (use-local-map (append map (current-local-map))))))
  327. (defun tmm-completion-delete-prompt ()
  328. (with-current-buffer standard-output
  329. (goto-char (point-min))
  330. (delete-region (point) (search-forward "Possible completions are:\n"))))
  331. (defun tmm-remove-inactive-mouse-face ()
  332. "Remove the mouse-face property from inactive menu items."
  333. (let ((inhibit-read-only t)
  334. (inactive-string
  335. (concat " " (make-string (length tmm-mid-prompt) ?\-)))
  336. next)
  337. (save-excursion
  338. (goto-char (point-min))
  339. (while (not (eobp))
  340. (setq next (next-single-char-property-change (point) 'mouse-face))
  341. (when (looking-at inactive-string)
  342. (remove-text-properties (point) next '(mouse-face))
  343. (add-text-properties (point) next '(face tmm-inactive)))
  344. (goto-char next)))
  345. (set-buffer-modified-p nil)))
  346. (defun tmm-add-prompt ()
  347. (unless tmm-c-prompt
  348. (error "No active menu entries"))
  349. (setq tmm-old-mb-map (tmm-define-keys t))
  350. (or tmm-completion-prompt
  351. (add-hook 'completion-setup-hook
  352. 'tmm-completion-delete-prompt 'append))
  353. (unwind-protect
  354. (minibuffer-completion-help)
  355. (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt))
  356. (with-current-buffer "*Completions*"
  357. (tmm-remove-inactive-mouse-face)
  358. (when tmm-completion-prompt
  359. (let ((inhibit-read-only t)
  360. (window (get-buffer-window "*Completions*")))
  361. (goto-char (point-min))
  362. (insert tmm-completion-prompt)
  363. (when window
  364. ;; Try to show everything just inserted and preserve height of
  365. ;; *Completions* window. This should fix a behavior described
  366. ;; in Bug#1291.
  367. (fit-window-to-buffer window nil nil nil nil t)))))
  368. (insert tmm-c-prompt))
  369. (defun tmm-shortcut ()
  370. "Choose the shortcut that the user typed."
  371. (interactive)
  372. (let ((c last-command-event) s)
  373. (if (symbolp tmm-shortcut-style)
  374. (setq c (funcall tmm-shortcut-style c)))
  375. (if (memq c tmm-short-cuts)
  376. (if (equal (buffer-name) "*Completions*")
  377. (progn
  378. (goto-char (point-min))
  379. (re-search-forward
  380. (concat "\\(^\\|[ \t]\\)" (char-to-string c) tmm-mid-prompt))
  381. (choose-completion))
  382. ;; In minibuffer
  383. (delete-region (minibuffer-prompt-end) (point-max))
  384. (dolist (elt tmm-km-list)
  385. (if (string=
  386. (substring (car elt) 0
  387. (min (1+ (length tmm-mid-prompt))
  388. (length (car elt))))
  389. (concat (char-to-string c) tmm-mid-prompt))
  390. (setq s (car elt))))
  391. (insert s)
  392. (exit-minibuffer)))))
  393. (defun tmm-goto-completions ()
  394. "Jump to the completions buffer."
  395. (interactive)
  396. (let ((prompt-end (minibuffer-prompt-end)))
  397. (setq tmm-c-prompt (buffer-substring prompt-end (point-max)))
  398. ;; FIXME: Why?
  399. (delete-region prompt-end (point-max)))
  400. (switch-to-buffer-other-window "*Completions*")
  401. (search-forward tmm-c-prompt)
  402. (search-backward tmm-c-prompt))
  403. (defun tmm-get-keymap (elt &optional in-x-menu)
  404. "Prepend (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'.
  405. The values are deduced from the argument ELT, that should be an
  406. element of keymap, an `x-popup-menu' argument, or an element of
  407. `x-popup-menu' argument (when IN-X-MENU is not-nil).
  408. This function adds the element only if it is not already present.
  409. It uses the free variable `tmm-table-undef' to keep undefined keys."
  410. (let (km str plist filter visible enable (event (car elt)))
  411. (setq elt (cdr elt))
  412. (if (eq elt 'undefined)
  413. (setq tmm-table-undef (cons (cons event nil) tmm-table-undef))
  414. (unless (assoc event tmm-table-undef)
  415. (cond ((if (listp elt)
  416. (or (keymapp elt) (eq (car elt) 'lambda))
  417. (and (symbolp elt) (fboundp elt)))
  418. (setq km elt))
  419. ((if (listp (cdr-safe elt))
  420. (or (keymapp (cdr-safe elt))
  421. (eq (car (cdr-safe elt)) 'lambda))
  422. (and (symbolp (cdr-safe elt)) (fboundp (cdr-safe elt))))
  423. (setq km (cdr elt))
  424. (and (stringp (car elt)) (setq str (car elt))))
  425. ((if (listp (cdr-safe (cdr-safe elt)))
  426. (or (keymapp (cdr-safe (cdr-safe elt)))
  427. (eq (car (cdr-safe (cdr-safe elt))) 'lambda))
  428. (and (symbolp (cdr-safe (cdr-safe elt)))
  429. (fboundp (cdr-safe (cdr-safe elt)))))
  430. (setq km (cddr elt))
  431. (and (stringp (car elt)) (setq str (car elt))))
  432. ((eq (car-safe elt) 'menu-item)
  433. ;; (menu-item TITLE COMMAND KEY ...)
  434. (setq plist (cdr-safe (cdr-safe (cdr-safe elt))))
  435. (when (consp (car-safe plist))
  436. (setq plist (cdr-safe plist)))
  437. (setq km (nth 2 elt))
  438. (setq str (eval (nth 1 elt)))
  439. (setq filter (plist-get plist :filter))
  440. (if filter
  441. (setq km (funcall filter km)))
  442. (setq visible (plist-get plist :visible))
  443. (if visible
  444. (setq km (and (eval visible) km)))
  445. (setq enable (plist-get plist :enable))
  446. (if enable
  447. (setq km (if (eval enable) km 'ignore))))
  448. ((if (listp (cdr-safe (cdr-safe (cdr-safe elt))))
  449. (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt))))
  450. (eq (car (cdr-safe (cdr-safe (cdr-safe elt)))) 'lambda))
  451. (and (symbolp (cdr-safe (cdr-safe (cdr-safe elt))))
  452. (fboundp (cdr-safe (cdr-safe (cdr-safe elt))))))
  453. ; New style of easy-menu
  454. (setq km (cdr (cddr elt)))
  455. (and (stringp (car elt)) (setq str (car elt))))
  456. ((stringp event) ; x-popup or x-popup element
  457. (setq str event)
  458. (setq event nil)
  459. (setq km (if (or in-x-menu (stringp (car-safe elt)))
  460. elt (cons 'keymap elt)))))
  461. (unless (or (eq km 'ignore) (null str))
  462. (let ((binding (where-is-internal km nil t)))
  463. (when binding
  464. (setq binding (key-description binding))
  465. ;; Try to align the keybindings.
  466. (let ((colwidth (min 30 (- (/ (window-width) 2) 10))))
  467. (setq str
  468. (concat str
  469. (make-string (max 2 (- colwidth
  470. (string-width str)
  471. (string-width binding)))
  472. ?\s)
  473. binding)))))))
  474. (and km (stringp km) (setq str km))
  475. ;; Verify that the command is enabled;
  476. ;; if not, don't mention it.
  477. (when (and km (symbolp km) (get km 'menu-enable))
  478. (setq km (if (eval (get km 'menu-enable)) km 'ignore)))
  479. (and km str
  480. (or (assoc str tmm-km-list)
  481. (push (cons str (cons event km)) tmm-km-list))))))
  482. (defun tmm-get-keybind (keyseq)
  483. "Return the current binding of KEYSEQ, merging prefix definitions.
  484. If KEYSEQ is a prefix key that has local and global bindings,
  485. we merge them into a single keymap which shows the proper order of the menu.
  486. However, for the menu bar itself, the value does not take account
  487. of `menu-bar-final-items'."
  488. (lookup-key (cons 'keymap (nreverse (current-active-maps))) keyseq))
  489. (provide 'tmm)
  490. ;;; tmm.el ends here