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