changeset 85434:1921151f9249

(mouse-minor-mode-menu, minor-mode-menu-from-indicator): Move here from bindings.el
author Glenn Morris <rgm@gnu.org>
date Fri, 19 Oct 2007 02:14:50 +0000
parents 04e61cffd3c0
children 26b4dfd428bb
files lisp/mouse.el
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mouse.el	Fri Oct 19 02:14:21 2007 +0000
+++ b/lisp/mouse.el	Fri Oct 19 02:14:50 2007 +0000
@@ -151,6 +151,26 @@
       ;; mouse-major-mode-menu was using `command-execute' instead.
       (call-interactively cmd))))
 
+(defun minor-mode-menu-from-indicator (indicator)
+  "Show menu, if any, for minor mode specified by INDICATOR.
+Interactively, INDICATOR is read using completion."
+  (interactive (list (completing-read "Minor mode indicator: "
+                                      (describe-minor-mode-completion-table-for-indicator))))
+  (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
+    (if minor-mode
+        (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist)))
+               (menu (and (keymapp map) (lookup-key map [menu-bar]))))
+          (if menu
+              (popup-menu menu)
+            (message "No menu for minor mode `%s'" minor-mode)))
+      (error "Cannot find minor mode for `%s'" indicator))))
+
+(defun mouse-minor-mode-menu (event)
+  "Show minor-mode menu for EVENT on minor modes area of the mode line."
+  (interactive "@e")
+  (let ((indicator (car (nth 4 (car (cdr event))))))
+    (minor-mode-menu-from-indicator indicator)))
+
 (defvar mouse-major-mode-menu-prefix)	; dynamically bound
 
 (defun mouse-major-mode-menu (event &optional prefix)