(gnus-group-set-mode-line): Allow user defined specs in the group
[bpt/emacs.git] / lisp / tmm.el
index 51fc76b..1d23ffb 100644 (file)
@@ -1,4 +1,4 @@
-;;; tmm.el - text mode access to menu-bar
+;;; tmm.el --- text mode access to menu-bar
 
 ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
 
@@ -43,6 +43,8 @@
 (defvar tmm-table-undef)
 
 ;;;###autoload (define-key global-map "\M-`" 'tmm-menubar)
+;;;###autoload (define-key global-map [f10] 'tmm-menubar)
+;;;###autoload (define-key global-map [menu-bar mouse-1] 'tmm-menubar)
 
 ;;;###autoload
 (defun tmm-menubar ()
@@ -73,7 +75,7 @@ See the documentation for `tmm-prompt'."
   "Press PageUp Key to reach this buffer from the minibuffer.
 Alternatively, you can use Up/Down keys (or your History keys) to change
 the item in the minibuffer, and press RET when you are done, or press the 
-marked letters to pick up your choice.  Type ESC ESC to cancel.
+marked letters to pick up your choice.  Type C-g or ESC ESC ESC to cancel.
 "
   "What insert on top of completion buffer.")
 
@@ -113,9 +115,12 @@ If the optional argument IN-POPUP is set, is argument-compatible with
                      tmm-km-list nil t nil
                      (cons 'history (* 2 history-len))))
             (save-excursion
-              (set-buffer "*Completions*")
-              (use-local-map tmm-old-comp-map)
-              (bury-buffer (current-buffer)))
+              (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt)
+              (if (get-buffer "*Completions*")
+                  (progn
+                    (set-buffer "*Completions*")
+                    (use-local-map tmm-old-comp-map)
+                    (bury-buffer (current-buffer)))))
             )))
     (setq bind (cdr (assoc out tmm-km-list)))
     (and (null bind)
@@ -176,23 +181,25 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
                  (cons (concat f tmm-mid-prompt str) (cdr elt)))))
            (reverse list))))
 
+(defun tmm-define-keys ()
+  (mapcar (lambda (str)
+           (define-key (current-local-map) str 'tmm-shortcut)
+           (define-key (current-local-map) (downcase str) 'tmm-shortcut))
+         tmm-short-cuts)
+  (define-key (current-local-map) [pageup] 'tmm-goto-completions)
+  (define-key (current-local-map) [prior] 'tmm-goto-completions)
+  (define-key (current-local-map) "\ev" 'tmm-goto-completions)
+  (define-key (current-local-map) "\C-n" 'next-history-element)
+  (define-key (current-local-map) "\C-p" 'previous-history-element))
+
 (defun tmm-add-prompt ()
   (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt)
   (make-local-hook 'minibuffer-exit-hook)
   (add-hook 'minibuffer-exit-hook 'tmm-delete-map nil t)
-  (let ((map (make-sparse-keymap)) (win (selected-window)))
-    (mapcar (lambda (str)
-             (define-key map str 'tmm-shortcut)
-             (define-key map (downcase str) 'tmm-shortcut))
-           tmm-short-cuts)
+  (let ((win (selected-window)))
     (setq tmm-old-mb-map (current-local-map))
-    (use-local-map (append map (cdr tmm-old-mb-map)))
-    (define-key (current-local-map) [pageup] 'tmm-goto-completions)
-    (define-key (current-local-map) [prior] 'tmm-goto-completions)
-    (define-key (current-local-map) "\ev" 'tmm-goto-completions)
-    (define-key (current-local-map) "\e\e" 'abort-recursive-edit)
-    (define-key (current-local-map) "\C-n" 'next-history-element)
-    (define-key (current-local-map) "\C-p" 'previous-history-element)
+    (use-local-map (append (make-sparse-keymap) tmm-old-mb-map))
+    (tmm-define-keys)
     ;; Get window and hide it for electric mode to get correct size
     (save-window-excursion 
       (let ((completions
@@ -208,7 +215,8 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
                                        ; not work in minibuffer
       (set-buffer (window-buffer (Electric-pop-up-window "*Completions*")))
       (setq tmm-old-comp-map (current-local-map))
-      (use-local-map (append map (cdr tmm-old-comp-map)))
+      (use-local-map (append (make-sparse-keymap) tmm-old-comp-map))
+      (tmm-define-keys)
       (select-window win)              ; Cannot use
                                        ; save-window-excursion, since
                                        ; it restores the size