diff options
| author | Richard M. Stallman | 1994-03-30 18:57:29 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-30 18:57:29 +0000 |
| commit | 8df69fb0327149fd8ddd8920b3620aed948fa5a0 (patch) | |
| tree | 04c02adaa40a32063c0dd4085f7e59f7d7152e9e | |
| parent | b65e3dd79eb5066d653e999c350a879c7e19886f (diff) | |
| download | emacs-8df69fb0327149fd8ddd8920b3620aed948fa5a0.tar.gz emacs-8df69fb0327149fd8ddd8920b3620aed948fa5a0.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/emacs-lisp/easymenu.el | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el index 0a489840133..90b4f55fe09 100644 --- a/lisp/emacs-lisp/easymenu.el +++ b/lisp/emacs-lisp/easymenu.el | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | ;;; easymenu.el --- support the easymenu interface for defining a menu. | 1 | ;;; easymenu.el --- support the easymenu interface for defining a menu. |
| 2 | 2 | ||
| 3 | ;; Keywords: emulations | ||
| 4 | |||
| 5 | ;; Copyright (C) 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1994 Free Software Foundation, Inc. |
| 6 | 4 | ||
| 5 | ;; Keywords: emulations | ||
| 6 | ;; Author: rms | ||
| 7 | |||
| 7 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 8 | 9 | ||
| 9 | ;; GNU Emacs is free software; you can redistribute it and/or modify | 10 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
| @@ -27,22 +28,26 @@ | |||
| 27 | ;;; Code: | 28 | ;;; Code: |
| 28 | 29 | ||
| 29 | ;;;###autoload | 30 | ;;;###autoload |
| 30 | (defun easy-menu-define (symbol maps doc menu) | 31 | (defmacro easy-menu-define (symbol maps doc menu) |
| 31 | "Define a menu bar submenu in maps MAPS, according to MENU. | 32 | "Define a menu bar submenu in maps MAPS, according to MENU. |
| 32 | The arguments SYMBOL and DOC are ignored; they are present for | 33 | The arguments SYMBOL and DOC are ignored; they are present for |
| 33 | compatibility only. In other Emacs versions they may be used | 34 | compatibility only. SYMBOL is not evaluated. In other Emacs versions |
| 34 | as a variable to hold the menu data, and a doc string for that variable. | 35 | these arguments may be used as a variable to hold the menu data, and a |
| 36 | doc string for that variable. | ||
| 35 | 37 | ||
| 36 | The first element of MENU must be a string. It is the menu bar item name. | 38 | The first element of MENU must be a string. It is the menu bar item name. |
| 37 | The rest of the elements are menu items. | 39 | The rest of the elements are menu items. |
| 38 | 40 | ||
| 39 | A menu item is usually a vector of three elements: [NAME CALLBACK t] | 41 | A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE] |
| 40 | 42 | ||
| 41 | NAME is a string--the menu item name. | 43 | NAME is a string--the menu item name. |
| 42 | 44 | ||
| 43 | CALLBACK is a command to run when the item is chosen, | 45 | CALLBACK is a command to run when the item is chosen, |
| 44 | or a list to evaluate when the item is chosen. | 46 | or a list to evaluate when the item is chosen. |
| 45 | 47 | ||
| 48 | ENABLE is a symbol; if its value is non-nil, the item is enabled | ||
| 49 | for selection. | ||
| 50 | |||
| 46 | A menu item can be a string. Then that string appears in the menu as | 51 | A menu item can be a string. Then that string appears in the menu as |
| 47 | unselectable text. A string consisting solely of hyphens is displayed | 52 | unselectable text. A string consisting solely of hyphens is displayed |
| 48 | as a solid horizontal line. | 53 | as a solid horizontal line. |
| @@ -51,12 +56,14 @@ A menu item can be a list. It is treated as a submenu. | |||
| 51 | The first element should be the submenu name. That's used as the | 56 | The first element should be the submenu name. That's used as the |
| 52 | menu item in the top-level menu. The cdr of the submenu list | 57 | menu item in the top-level menu. The cdr of the submenu list |
| 53 | is a list of menu items, as above." | 58 | is a list of menu items, as above." |
| 54 | (or (keymapp maps) (setq maps (list maps))) | 59 | (` (let* ((maps (, maps)) |
| 55 | (let ((keymap (easy-menu-keymap (car menu) (cdr menu)))) | 60 | (menu (, menu)) |
| 56 | (while maps | 61 | (keymap (easy-menu-keymap (car menu) (cdr menu)))) |
| 57 | (define-key (car maps) (vector 'menu-bar (intern (car menu))) | 62 | (and (keymapp maps) (setq maps (list maps))) |
| 58 | (cons (car menu) keymap)) | 63 | (while maps |
| 59 | (setq maps (cdr maps))))) | 64 | (define-key (car maps) (vector 'menu-bar (intern (car menu))) |
| 65 | (cons (car menu) keymap)) | ||
| 66 | (setq maps (cdr maps)))))) | ||
| 60 | 67 | ||
| 61 | (defvar easy-menu-item-count 0) | 68 | (defvar easy-menu-item-count 0) |
| 62 | 69 | ||
| @@ -76,16 +83,15 @@ is a list of menu items, as above." | |||
| 76 | (setq name (if (string-match "^-+$" item) "" item))) | 83 | (setq name (if (string-match "^-+$" item) "" item))) |
| 77 | ((consp item) | 84 | ((consp item) |
| 78 | (setq command (easy-menu-keymap (car item) (cdr item))) | 85 | (setq command (easy-menu-keymap (car item) (cdr item))) |
| 79 | (setq name (car item))) | 86 | (setq name (concat (car item) "..."))) |
| 80 | ((vectorp item) | 87 | ((vectorp item) |
| 81 | (setq command (make-symbol (format "menu-function-%d" | 88 | (setq command (make-symbol (format "menu-function-%d" |
| 82 | easy-menu-item-count))) | 89 | easy-menu-item-count))) |
| 83 | (setq enabler (make-symbol (format "menu-function-%d-enabler" | ||
| 84 | easy-menu-item-count))) | ||
| 85 | (setq easy-menu-item-count (1+ easy-menu-item-count)) | 90 | (setq easy-menu-item-count (1+ easy-menu-item-count)) |
| 86 | (put command 'menu-enable enabler) | 91 | (put command 'menu-enable (aref item 2)) |
| 87 | (set enabler (aref item 2)) | ||
| 88 | (setq name (aref item 0)) | 92 | (setq name (aref item 0)) |
| 93 | (if (keymapp callback) | ||
| 94 | (setq name (concat name " ..."))) | ||
| 89 | (if (symbolp callback) | 95 | (if (symbolp callback) |
| 90 | (fset command callback) | 96 | (fset command callback) |
| 91 | (fset command (list 'lambda () '(interactive) callback))))) | 97 | (fset command (list 'lambda () '(interactive) callback))))) |
| @@ -98,6 +104,10 @@ is a list of menu items, as above." | |||
| 98 | (setq menu-items (cdr menu-items))) | 104 | (setq menu-items (cdr menu-items))) |
| 99 | menu)) | 105 | menu)) |
| 100 | 106 | ||
| 107 | (defmacro easy-menu-remove (menu)) | ||
| 108 | |||
| 109 | (defmacro easy-menu-add (menu &optional map)) | ||
| 110 | |||
| 101 | (provide 'easymenu) | 111 | (provide 'easymenu) |
| 102 | 112 | ||
| 103 | ;;; easymenu.el ends here | 113 | ;;; easymenu.el ends here |