unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* show minor-mode menu when you click its mode-line lighter
@ 2007-09-27 22:21 Drew Adams
  2007-09-28 19:04 ` Richard Stallman
  0 siblings, 1 reply; 18+ messages in thread
From: Drew Adams @ 2007-09-27 22:21 UTC (permalink / raw)
  To: Emacs-Devel

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

Attached is a patch that makes a `mouse-1' click on a minor-mode lighter in
the mode line raise its menu-bar menu, if any, as a popup.

This is analogous to what `mouse-1' does when you click the major-mode
lighter. Each minor-mode lighter brings up its own menu. If a minor mode has
no menu-bar menu, then `mouse-1' displays a message stating that.

Currently, `mouse-1' does nothing here, so this is an addition.

Example: Minor mode Icicles has lighter "Icy" in the mode line, and it has a
menu-bar menu `Icicles'. Whether or not the menu-bar is showing, if you
click the lighter "Icy" then the `Icicles' menu pops up.


[-- Attachment #2: bindings-2007-09-27.patch --]
[-- Type: application/octet-stream, Size: 7930 bytes --]

*** bindings-CVS-2007-09-27.el	Thu Sep 27 14:43:48 2007
--- bindings-patched-2007-09-27.el	Thu Sep 27 15:07:04 2007
***************
*** 289,294 ****
--- 289,295 ----
  
  (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)
***************
*** 304,346 ****
  	"mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0")
         (dashes (propertize "--" 'help-echo help-echo))
         (standard-mode-line-format
! 	(list
! 	 "%e"
! 	 (propertize "-" 'help-echo help-echo)
! 	 'mode-line-mule-info
! 	 'mode-line-client
! 	 'mode-line-modified
! 	 'mode-line-remote
! 	 'mode-line-frame-identification
! 	 'mode-line-buffer-identification
! 	 (propertize "   " 'help-echo help-echo)
! 	 'mode-line-position
! 	 '(vc-mode vc-mode)
! 	 (propertize "  " 'help-echo help-echo)
! 	 'mode-line-modes
  	 `(which-func-mode ("" which-func-format ,dashes))
  	 `(global-mode-string (,dashes global-mode-string))
  	 (propertize "-%-" 'help-echo help-echo)))
         (standard-mode-line-modes
! 	(list
! 	 (propertize "%[(" 'help-echo help-echo)
  	 `(:propertize ("" mode-name)
! 		       help-echo "mouse-1: major mode, mouse-2: major mode help, mouse-3: toggle minor modes"
  		       mouse-face mode-line-highlight
  		       local-map ,mode-line-major-mode-keymap)
  	 '("" mode-line-process)
  	 `(:propertize ("" minor-mode-alist)
  		       mouse-face mode-line-highlight
! 		       help-echo "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
  		     'local-map (make-mode-line-mouse-map
  				 'mouse-2 #'mode-line-widen))
  	 (propertize ")%]--" 'help-echo help-echo)))
! 
!        (standard-mode-line-position
! 	`((-3 ,(propertize "%p" 'help-echo help-echo))
  	  (size-indication-mode
  	   (8 ,(propertize " of %I" 'help-echo help-echo)))
  	  (line-number-mode
--- 305,338 ----
          "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0")
         (dashes (propertize "--" 'help-echo help-echo))
         (standard-mode-line-format
! 	(list "%e"
!               (propertize "-" 'help-echo help-echo) 'mode-line-mule-info
!               'mode-line-client 'mode-line-modified 'mode-line-remote
!               'mode-line-frame-identification 'mode-line-buffer-identification
!               (propertize "   " 'help-echo help-echo) 'mode-line-position '(vc-mode vc-mode)
!               (propertize "  " 'help-echo help-echo) 'mode-line-modes
                `(which-func-mode ("" which-func-format ,dashes))
                `(global-mode-string (,dashes global-mode-string))
                (propertize "-%-" 'help-echo help-echo)))
         (standard-mode-line-modes
!         (list (propertize "%[(" 'help-echo help-echo)
                `(:propertize ("" mode-name)
!                             help-echo "mouse-1: major-mode menu, mouse-2: major-mode help, \
! mouse-3: toggle minor modes"
                              mouse-face mode-line-highlight
                              local-map ,mode-line-major-mode-keymap)
                '("" mode-line-process)
                `(:propertize ("" minor-mode-alist)
                              mouse-face mode-line-highlight
!                             help-echo "mouse-1: minor-mode menu, 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
                            'local-map (make-mode-line-mouse-map
                                        'mouse-2 #'mode-line-widen))
                (propertize ")%]--" 'help-echo help-echo)))
!        (standard-mode-line-position `((-3 ,(propertize "%p" 'help-echo help-echo))
                                        (size-indication-mode
                                         (8 ,(propertize " of %I" 'help-echo help-echo)))
                                        (line-number-mode
***************
*** 349,366 ****
  	     (6 ,(propertize " L%l" 'help-echo help-echo))))
  	   ((column-number-mode
  	     (5 ,(propertize " C%c" 'help-echo help-echo))))))))
- 
    (setq-default mode-line-format standard-mode-line-format)
!   (put 'mode-line-format 'standard-value
!        (list `(quote ,standard-mode-line-format)))
  
    (setq-default mode-line-modes standard-mode-line-modes)
!   (put 'mode-line-modes 'standard-value
!        (list `(quote ,standard-mode-line-modes)))
  
    (setq-default mode-line-position standard-mode-line-position)
!   (put 'mode-line-position 'standard-value
!        (list `(quote ,standard-mode-line-position))))
  
  (defvar mode-line-buffer-identification-keymap
    ;; Add menu of buffer operations to the buffer identification part
--- 341,354 ----
                                           (6 ,(propertize " L%l" 'help-echo help-echo))))
                                         ((column-number-mode
                                           (5 ,(propertize " C%c" 'help-echo help-echo))))))))
    (setq-default mode-line-format standard-mode-line-format)
!   (put 'mode-line-format 'standard-value (list `(quote ,standard-mode-line-format)))
  
    (setq-default mode-line-modes standard-mode-line-modes)
!   (put 'mode-line-modes 'standard-value (list `(quote ,standard-mode-line-modes)))
  
    (setq-default mode-line-position standard-mode-line-position)
!   (put 'mode-line-position 'standard-value (list `(quote ,standard-mode-line-position))))
  
  (defvar mode-line-buffer-identification-keymap
    ;; Add menu of buffer operations to the buffer identification part
***************
*** 492,499 ****
    (interactive "@e")
    (x-popup-menu event mode-line-mode-menu))
  
  (defun mode-line-minor-mode-help (event)
!   "Describe minor mode for EVENT occurred on minor modes area of the mode line."
    (interactive "@e")
    (let ((indicator (car (nth 4 (car (cdr event))))))
      (describe-minor-mode-from-indicator indicator)))
--- 480,507 ----
    (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) ; " Icy"
+   "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 on minor modes area of the mode line."
    (interactive "@e")
    (let ((indicator (car (nth 4 (car (cdr event))))))
      (describe-minor-mode-from-indicator indicator)))

Diff finished.  Thu Sep 27 15:07:29 2007

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2007-10-18  4:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-27 22:21 show minor-mode menu when you click its mode-line lighter Drew Adams
2007-09-28 19:04 ` Richard Stallman
2007-10-02 21:18   ` Drew Adams
2007-10-03 18:37     ` Richard Stallman
2007-10-03 23:17       ` Michaël Cadilhac
2007-10-04 16:59         ` Drew Adams
2007-10-04 17:27         ` Richard Stallman
2007-10-04 18:55           ` Dan Nicolaescu
2007-10-08 18:03             ` Richard Stallman
2007-10-08 18:10               ` Glenn Morris
2007-10-08 15:35           ` Michaël Cadilhac
2007-10-08 16:46             ` Drew Adams
2007-10-09  1:14               ` Richard Stallman
2007-10-09  2:39                 ` Drew Adams
2007-10-10 13:01                   ` Richard Stallman
2007-10-18  4:10                   ` Glenn Morris
2007-10-09  1:14             ` Richard Stallman
2007-10-09 16:48       ` Davis Herring

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).