aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-02-21 09:15:32 +0000
committerDan Nicolaescu2008-02-21 09:15:32 +0000
commitfb1a03c9f5ae50bdc573599fcec0dfceb97480a7 (patch)
tree87643fa659f0ede260d50c530bc8e3586fa19460
parent796abee9d8ff0bc26c4bd6f5a423cc73b7a15e9a (diff)
downloademacs-fb1a03c9f5ae50bdc573599fcec0dfceb97480a7.tar.gz
emacs-fb1a03c9f5ae50bdc573599fcec0dfceb97480a7.zip
* mouse.el (minor-mode-menu-from-indicator): Create a menu with a
"Turn off" and a "Help" entry when the minor mode has no menu.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/mouse.el37
2 files changed, 31 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 132a8cee142..7645300c6aa 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12008-02-21 Drew Adams <drew.adams@oracle.com>
2
3 * mouse.el (minor-mode-menu-from-indicator): Create a menu with a
4 "Turn off" and a "Help" entry when the minor mode has no menu.
5
12008-02-21 Dan Nicolaescu <dann@ics.uci.edu> 62008-02-21 Dan Nicolaescu <dann@ics.uci.edu>
2 7
3 * vc.el (vc-status-mark, vc-status-unmark): New functions. 8 * vc.el (vc-status-mark, vc-status-unmark): New functions.
diff --git a/lisp/mouse.el b/lisp/mouse.el
index a0e823e2098..8b3195ac010 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -152,18 +152,33 @@ PREFIX is the prefix argument (if any) to pass to the command."
152 (call-interactively cmd)))) 152 (call-interactively cmd))))
153 153
154(defun minor-mode-menu-from-indicator (indicator) 154(defun minor-mode-menu-from-indicator (indicator)
155 "Show menu, if any, for minor mode specified by INDICATOR. 155 "Show menu for minor mode specified by INDICATOR.
156Interactively, INDICATOR is read using completion." 156Interactively, INDICATOR is read using completion.
157 (interactive (list (completing-read "Minor mode indicator: " 157If there is no menu defined for the minor mode, then create one with
158 (describe-minor-mode-completion-table-for-indicator)))) 158items `Turn Off' and `Help'."
159 (interactive
160 (list (completing-read
161 "Minor mode indicator: "
162 (describe-minor-mode-completion-table-for-indicator))))
159 (let ((minor-mode (lookup-minor-mode-from-indicator indicator))) 163 (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
160 (if minor-mode 164 (unless minor-mode (error "Cannot find minor mode for `%s'" indicator))
161 (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist))) 165 (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist)))
162 (menu (and (keymapp map) (lookup-key map [menu-bar])))) 166 (menu (and (keymapp map) (lookup-key map [menu-bar]))))
163 (if menu 167 (unless menu
164 (popup-menu menu) 168 (setq menu
165 (message "No menu for minor mode `%s'" minor-mode))) 169 `(keymap
166 (error "Cannot find minor mode for `%s'" indicator)))) 170 (,(intern indicator) ,indicator
171 keymap
172 (turn-off menu-item "Turn Off minor mode"
173 (lambda ()
174 (interactive)
175 (,minor-mode -1)
176 (message ,(format "`%S' turned OFF" minor-mode))))
177 (help menu-item "Help for minor mode"
178 (lambda () (interactive)
179 (describe-function
180 ',minor-mode)))))))
181 (popup-menu menu))))
167 182
168(defun mouse-minor-mode-menu (event) 183(defun mouse-minor-mode-menu (event)
169 "Show minor-mode menu for EVENT on minor modes area of the mode line." 184 "Show minor-mode menu for EVENT on minor modes area of the mode line."