changeset 92434:1fe5dc1b18dd

(mode-line-column-line-number-mode-map): New variable. (standard-mode-line-position): Use it to add a menu for toggling column number and line number display.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 03 Mar 2008 08:30:18 +0000
parents ff7a3592c48b
children d93568041d5e
files lisp/ChangeLog lisp/bindings.el
diffstat 2 files changed, 39 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Mar 03 06:32:13 2008 +0000
+++ b/lisp/ChangeLog	Mon Mar 03 08:30:18 2008 +0000
@@ -1,3 +1,9 @@
+2008-03-03  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* bindings.el (mode-line-column-line-number-mode-map): New variable.
+	(standard-mode-line-position): Use it to add a menu for toggling
+	column number and line number display.
+
 2008-03-03  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacs-lisp/bytecomp.el (byte-compile-maybe-guarded):
--- a/lisp/bindings.el	Mon Mar 03 06:32:13 2008 +0000
+++ b/lisp/bindings.el	Mon Mar 03 08:30:18 2008 +0000
@@ -299,6 +299,21 @@
     map) "\
 Keymap to display on minor modes.")
 
+(defvar mode-line-column-line-number-mode-map
+  (let ((map (make-sparse-keymap))
+	(menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
+    (define-key menu-map [line-number-mode]
+      `(menu-item ,(purecopy "Display Line Numbers") line-number-mode
+		  :help "Toggle displaying line numbers in the mode-line"
+		  :button (:toggle . line-number-mode)))
+    (define-key menu-map [column-number-mode]
+      `(menu-item ,(purecopy "Display Column Numbers") column-number-mode
+		  :help "Toggle displaying column numbers in the mode-line"
+		  :button (:toggle . column-number-mode)))
+    (define-key map [mode-line down-mouse-1] menu-map)
+    map) "\
+Keymap to display on column and line numbers.")
+
 (let* ((help-echo
 	;; The multi-line message doesn't work terribly well on the
 	;; bottom mode line...  Better ideas?
@@ -352,27 +367,37 @@
 	 (propertize ")%]--" 'help-echo help-echo)))
 
        (standard-mode-line-position
-	`((-3 ,(propertize "%p" 'help-echo help-echo))
+	`((-3 ,(propertize
+		"%p"
+		'local-map mode-line-column-line-number-mode-map
+		;; XXX needs better description
+		'help-echo "Size indication mode\n\
+mouse-1: Display Line and Column Mode Menu"))
 	  (size-indication-mode
 	   (8 ,(propertize
 		" of %I"
+		'local-map mode-line-column-line-number-mode-map
 		;; XXX needs better description
-		'help-echo (format "Size indication mode\n%s" help-echo))))
+		'help-echo "Size indication mode\n\
+mouse-1: Display Line and Column Mode Menu")))
 	  (line-number-mode
 	   ((column-number-mode
 	     (10 ,(propertize
 		   " (%l,%c)"
-		   'help-echo
-		   (format "Line number and Column number\n%s" help-echo)))
+		   'local-map mode-line-column-line-number-mode-map
+		   'help-echo "Line number and Column number\n\
+mouse-1: Display Line and Column Mode Menu"))
 	     (6 ,(propertize
 		  " L%l"
-		  'help-echo
-		  (format "Line number\n%s" help-echo)))))
+		  'local-map mode-line-column-line-number-mode-map
+		  'help-echo "Line Number\n\
+mouse-1: Display Line and Column Mode Menu"))))
 	   ((column-number-mode
 	     (5 ,(propertize
 		  " C%c"
-		  'help-echo
-		  (format "Column number\n%s" help-echo)))))))))
+		  'local-map mode-line-column-line-number-mode-map
+		  'help-echo "Column number\n\
+mouse-1: Display Line and Column Mode Menu"))))))))
 
   (setq-default mode-line-format standard-mode-line-format)
   (put 'mode-line-format 'standard-value