/[emacs]/emacs/lisp/tmm.el
ViewVC logotype

Diff of /emacs/lisp/tmm.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.36 by pj, Sun Nov 25 11:31:50 2001 UTC revision 1.37 by pj, Sun Jan 27 11:17:06 2002 UTC
# Line 1  Line 1 
1  ;;; tmm.el --- text mode access to menu-bar  ;;; tmm.el --- text mode access to menu-bar
2    
3  ;; Copyright (C) 1994, 1995, 1996, 2000, 2001  ;; Copyright (C) 1994, 1995, 1996, 2000, 2001, 2002
4  ;;   Free Software Foundation, Inc.  ;;   Free Software Foundation, Inc.
5    
6  ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu>  ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu>
7  ;; Maintainer: FSF  ;; Maintainer: FSF
8    ;; Keywords: convenience
9    
10  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
11    
# Line 25  Line 26 
26    
27  ;;; Commentary:  ;;; Commentary:
28    
29  ;; To use this package add  ;; This package provides text mode access to the menu bar.
   
 ;; (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.  
30    
31  ;;; Code:  ;;; Code:
32    
# Line 101  See the documentation for `tmm-prompt'." Line 96  See the documentation for `tmm-prompt'."
96    (tmm-menubar (car (posn-x-y (event-start event)))))    (tmm-menubar (car (posn-x-y (event-start event)))))
97    
98  (defcustom tmm-mid-prompt "==>"  (defcustom tmm-mid-prompt "==>"
99    "*String to insert between shortcut and menu item.    "*String to insert between shortcut and menu item.
100  If nil, there will be no shortcuts. It should not consist only of spaces,  If nil, there will be no shortcuts. It should not consist only of spaces,
101  or else the correct item might not be found in the `*Completions*' buffer."  or else the correct item might not be found in the `*Completions*' buffer."
102    :type 'string    :type 'string
# Line 110  or else the correct item might not be fo Line 105  or else the correct item might not be fo
105  (defvar tmm-mb-map nil  (defvar tmm-mb-map nil
106    "A place to store minibuffer map.")    "A place to store minibuffer map.")
107    
108  (defcustom tmm-completion-prompt  (defcustom tmm-completion-prompt
109    "Press PageUp Key to reach this buffer from the minibuffer.    "Press PageUp Key to reach this buffer from the minibuffer.
110  Alternatively, you can use Up/Down keys (or your History keys) to change  Alternatively, you can use Up/Down keys (or your History keys) to change
111  the item in the minibuffer, and press RET when you are done, or press the  the item in the minibuffer, and press RET when you are done, or press the
112  marked letters to pick up your choice.  Type C-g or ESC ESC ESC to cancel.  marked letters to pick up your choice.  Type C-g or ESC ESC ESC to cancel.
113  "  "
114    "*Help text to insert on the top of the completion buffer.    "*Help text to insert on the top of the completion buffer.
# Line 123  in which case the standard introduction Line 118  in which case the standard introduction
118    :group 'tmm)    :group 'tmm)
119    
120  (defcustom tmm-shortcut-style '(downcase upcase)  (defcustom tmm-shortcut-style '(downcase upcase)
121    "*What letters to use as menu shortcuts.    "*What letters to use as menu shortcuts.
122  Must be either one of the symbols `downcase' or `upcase',  Must be either one of the symbols `downcase' or `upcase',
123  or else a list of the two in the order you prefer."  or else a list of the two in the order you prefer."
124    :type '(choice (const downcase)    :type '(choice (const downcase)
125                   (const upcase)                   (const upcase)
# Line 133  or else a list of the two in the order y Line 128  or else a list of the two in the order y
128    
129  (defcustom tmm-shortcut-words 2  (defcustom tmm-shortcut-words 2
130    "*How many successive words to try for shortcuts, nil means all.    "*How many successive words to try for shortcuts, nil means all.
131  If you use only one of `downcase' or `upcase' for `tmm-shortcut-style',  If you use only one of `downcase' or `upcase' for `tmm-shortcut-style',
132  specify nil for this variable."  specify nil for this variable."
133    :type '(choice integer (const nil))    :type '(choice integer (const nil))
134    :group 'tmm)    :group 'tmm)
# Line 234  Its value should be an event that has a Line 229  Its value should be an event that has a
229             ;; We just did the inner level of a -popup menu.             ;; We just did the inner level of a -popup menu.
230             choice)             choice)
231            ;; We just did the outer level.  Do the inner level now.            ;; We just did the outer level.  Do the inner level now.
232            (not-menu (tmm-prompt choice t))            (not-menu (tmm-prompt choice t))
233            ;; We just handled a menu keymap and found another keymap.            ;; We just handled a menu keymap and found another keymap.
234            ((keymapp choice)            ((keymapp choice)
235             (if (symbolp choice)             (if (symbolp choice)
# Line 265  Stores a list of all the shortcuts in th Line 260  Stores a list of all the shortcuts in th
260  (defsubst tmm-add-one-shortcut (elt)  (defsubst tmm-add-one-shortcut (elt)
261  ;; uses the free vars tmm-next-shortcut-digit and tmm-short-cuts  ;; uses the free vars tmm-next-shortcut-digit and tmm-short-cuts
262    (let* ((str (car elt))    (let* ((str (car elt))
263          (paren (string-match "(" str))            (paren (string-match "(" str))
264          (pos 0) (word 0) char)          (pos 0) (word 0) char)
265      (catch 'done                        ; ??? is this slow?      (catch 'done                        ; ??? is this slow?
266        (while (and (or (not tmm-shortcut-words) ; no limit on words        (while (and (or (not tmm-shortcut-words) ; no limit on words
# Line 274  Stores a list of all the shortcuts in th Line 269  Stores a list of all the shortcuts in th
269                    (not (and paren (> pos paren)))) ; don't go past "(binding.."                    (not (and paren (> pos paren)))) ; don't go past "(binding.."
270          (if (or (= pos 0)          (if (or (= pos 0)
271                  (/= (aref str (1- pos)) ?.)) ; avoid file extensions                  (/= (aref str (1- pos)) ?.)) ; avoid file extensions
272              (let ((shortcut-style                              (let ((shortcut-style
273                     (if (listp tmm-shortcut-style) ; convert to list                     (if (listp tmm-shortcut-style) ; convert to list
274                         tmm-shortcut-style                         tmm-shortcut-style
275                       (list tmm-shortcut-style))))                       (list tmm-shortcut-style))))
# Line 330  Stores a list of all the shortcuts in th Line 325  Stores a list of all the shortcuts in th
325    (let ((win (selected-window)))    (let ((win (selected-window)))
326      (setq tmm-old-mb-map (tmm-define-keys t))      (setq tmm-old-mb-map (tmm-define-keys t))
327      ;; Get window and hide it for electric mode to get correct size      ;; Get window and hide it for electric mode to get correct size
328      (save-window-excursion      (save-window-excursion
329        (let ((completions        (let ((completions
330               (mapcar 'car minibuffer-completion-table)))               (mapcar 'car minibuffer-completion-table)))
331          (or tmm-completion-prompt          (or tmm-completion-prompt
# Line 375  Stores a list of all the shortcuts in th Line 370  Stores a list of all the shortcuts in th
370            (delete-region (minibuffer-prompt-end) (point-max))            (delete-region (minibuffer-prompt-end) (point-max))
371            (mapc (lambda (elt)            (mapc (lambda (elt)
372                    (if (string=                    (if (string=
373                         (substring (car elt) 0                         (substring (car elt) 0
374                                    (min (1+ (length tmm-mid-prompt))                                    (min (1+ (length tmm-mid-prompt))
375                                         (length (car elt))))                                         (length (car elt))))
376                         (concat (char-to-string c) tmm-mid-prompt))                         (concat (char-to-string c) tmm-mid-prompt))
# Line 393  Stores a list of all the shortcuts in th Line 388  Stores a list of all the shortcuts in th
388    (search-forward tmm-c-prompt)    (search-forward tmm-c-prompt)
389    (search-backward tmm-c-prompt))    (search-backward tmm-c-prompt))
390    
391  (defun tmm-get-keymap (elt &optional in-x-menu)  (defun tmm-get-keymap (elt &optional in-x-menu)
392    "Prepends (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'.    "Prepends (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'.
393  The values are deduced from the argument ELT, that should be an  The values are deduced from the argument ELT, that should be an
394  element of keymap, an `x-popup-menu' argument, or an element of  element of keymap, an `x-popup-menu' argument, or an element of
395  `x-popup-menu' argument (when IN-X-MENU is not-nil).  `x-popup-menu' argument (when IN-X-MENU is not-nil).
396  This function adds the element only if it is not already present.  This function adds the element only if it is not already present.
397  It uses the free variable `tmm-table-undef' to keep undefined keys."  It uses the free variable `tmm-table-undef' to keep undefined keys."
398    (let (km str cache plist filter (event (car elt)))    (let (km str cache plist filter visible (event (car elt)))
399      (setq elt (cdr elt))      (setq elt (cdr elt))
400      (if (eq elt 'undefined)      (if (eq elt 'undefined)
401          (setq tmm-table-undef (cons (cons event nil) tmm-table-undef))          (setq tmm-table-undef (cons (cons event nil) tmm-table-undef))
# Line 438  It uses the free variable `tmm-table-und Line 433  It uses the free variable `tmm-table-und
433                 (setq filter (plist-get plist :filter))                 (setq filter (plist-get plist :filter))
434                 (if filter                 (if filter
435                     (setq km (funcall filter km)))                     (setq km (funcall filter km)))
436                   (setq visible (plist-get plist :visible))
437                   (if visible
438                       (setq km (and (eval visible) km)))
439                 (and str                 (and str
440                      (consp (nth 3 elt))                      (consp (nth 3 elt))
441                      (stringp (cdr (nth 3 elt))) ; keyseq cache                      (stringp (cdr (nth 3 elt))) ; keyseq cache
# Line 489  of `menu-bar-final-items'." Line 487  of `menu-bar-final-items'."
487          (progn          (progn
488            ;; Otherwise, it is a prefix, so make a list of the subcommands.            ;; Otherwise, it is a prefix, so make a list of the subcommands.
489            ;; Make a list of all the bindings in all the keymaps.            ;; Make a list of all the bindings in all the keymaps.
490            (setq allbind (mapcar 'cdr (minor-mode-key-binding keyseq)))            (setq allbind (mapcar 'cdr (minor-mode-key-binding keyseq)))
491            (setq allbind (cons (local-key-binding keyseq) allbind))            (setq allbind (cons (local-key-binding keyseq) allbind))
492            (setq allbind (cons (global-key-binding keyseq) allbind))            (setq allbind (cons (global-key-binding keyseq) allbind))
493            ;; Merge all the elements of ALLBIND into one keymap.            ;; Merge all the elements of ALLBIND into one keymap.

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26