From fe1afc9b878fa523c24cee0435fbfa7ef17331bc Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 18 Oct 2007 04:08:42 +0000 Subject: [PATCH] Drew Adams (mode-line-minor-mode-keymap): Add mouse-minor-mode-menu on mouse-1. (mode-line-modes): Add mouse-1 to help-echo text. (mouse-minor-mode-menu, minor-mode-menu-from-indicator): New functions. (mode-line-minor-mode-help): Doc fix. --- lisp/ChangeLog | 9 +++++++++ lisp/bindings.el | 25 +++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8e0853ea612..c57c5aaacff 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2007-10-18 Drew Adams + + * bindings.el (mode-line-minor-mode-keymap): + Add mouse-minor-mode-menu on mouse-1. + (mode-line-modes): Add mouse-1 to help-echo text. + (mouse-minor-mode-menu, minor-mode-menu-from-indicator): + New functions. + (mode-line-minor-mode-help): Doc fix. + 2007-10-17 Juri Linkov * textmodes/fill.el (fill-paragraph-or-region): Remove function diff --git a/lisp/bindings.el b/lisp/bindings.el index 2ca7c8afea8..ad7470e07e3 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -289,6 +289,7 @@ Keymap to display on major mode.") (defvar mode-line-minor-mode-keymap (let ((map (make-sparse-keymap))) + (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu) (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help) (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1) (define-key map [header-line down-mouse-3] 'mode-line-mode-menu-1) @@ -331,7 +332,7 @@ Keymap to display on minor modes.") '("" mode-line-process) `(:propertize ("" minor-mode-alist) mouse-face mode-line-highlight - help-echo "mouse-2: minor mode help, mouse-3: toggle minor modes" + help-echo "mouse-1: minor mode, mouse-2: minor mode help, mouse-3: toggle minor modes" local-map ,mode-line-minor-mode-keymap) (propertize "%n" 'help-echo "mouse-2: widen" 'mouse-face 'mode-line-highlight @@ -492,8 +493,28 @@ Menu of mode operations in the mode line.") (interactive "@e") (x-popup-menu event mode-line-mode-menu)) +(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))) + +(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 mode-line-minor-mode-help (event) - "Describe minor mode for EVENT occurred on minor modes area of the mode line." + "Describe minor mode for EVENT on minor modes area of the mode line." (interactive "@e") (let ((indicator (car (nth 4 (car (cdr event)))))) (describe-minor-mode-from-indicator indicator))) -- 2.39.2