]> code.delx.au - gnu-emacs/blobdiff - lisp/tmm.el
(ps-print-preprint): Special handling if
[gnu-emacs] / lisp / tmm.el
index 868b07b98a499e93d39cef58e9631e8d0d1f1fe5..b648b9223187fc83d11b41462bf202bd2d40730e 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tmm.el --- text mode access to menu-bar
 
-;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu>
 ;; Maintainer: FSF
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
-;;; Commentary ============================================================
+;;; Commentary:
 
-;;; To use this package add 
+;; To use this package add 
 
-;;; (autoload 'tmm-menubar 'tmm "Text mode substitute for menubar" t) 
-;;; (global-set-key [f10] 'tmm-menubar)
+;; (autoload 'tmm-menubar 'tmm "Text mode substitute for menubar" t) 
+;; (global-set-key [f10] 'tmm-menubar)
+;; to your .emacs file. You can also add your own access to different
+;; menus available in Window System Emacs modeling definition after
+;; tmm-menubar.
 
-;;; to your .emacs file. You can also add your own access to different
-;;; menus available in Window System Emacs modelling definition after
-;;; tmm-menubar.
+;;; Code:
 
 (require 'electric)
 
@@ -82,6 +84,7 @@ we make that menu bar item (the one at that position) the default choice."
          (setq menu-bar-item (car this-one))))
     (tmm-prompt menu-bar nil menu-bar-item)))
 
+;;;###autoload
 (defun tmm-menubar-mouse (event)
   "Text-mode emulation of looking and choosing from a menubar.
 This command is used when you click the mouse in the menubar
@@ -211,7 +214,9 @@ Its value should be an event that has a binding in MENU."
          ;; We just handled a menu keymap and found a command.
          (choice
           (if chosen-string
-              (call-interactively choice)
+              (progn
+                (setq last-command-event chosen-string)
+                (call-interactively choice))
             choice)))))
 
 
@@ -243,16 +248,18 @@ 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 ()
+(defun tmm-define-keys (minibuffer)
   (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))
+  (if minibuffer
+      (progn
+       (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)
@@ -261,7 +268,7 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
   (let ((win (selected-window)))
     (setq tmm-old-mb-map (current-local-map))
     (use-local-map (append (make-sparse-keymap) tmm-old-mb-map))
-    (tmm-define-keys)
+    (tmm-define-keys t)
     ;; Get window and hide it for electric mode to get correct size
     (save-window-excursion 
       (let ((completions
@@ -278,7 +285,7 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
       (set-buffer (window-buffer (Electric-pop-up-window "*Completions*")))
       (setq tmm-old-comp-map (current-local-map))
       (use-local-map (append (make-sparse-keymap) tmm-old-comp-map))
-      (tmm-define-keys)
+      (tmm-define-keys nil)
       (select-window win)              ; Cannot use
                                        ; save-window-excursion, since
                                        ; it restores the size
@@ -379,7 +386,7 @@ It uses the free variable `tmm-table-undef' to keep undefined keys."
 
 (defun tmm-get-keybind (keyseq)
   "Return the current binding of KEYSEQ, merging prefix definitions.
-If KEYSEQ is a prefix key that has local and gloibal bindings,
+If KEYSEQ is a prefix key that has local and global bindings,
 we merge them into a single keymap which shows the proper order of the menu.
 However, for the menu bar itself, the value does not take account
 of `menu-bar-final-items'."
@@ -411,8 +418,6 @@ of `menu-bar-final-items'."
 
 (add-hook 'calendar-load-hook (lambda () (require 'cal-menu)))
 
-
 (provide 'tmm)
 
-
 ;;; tmm.el ends here