changeset 33261:a3294ec7a032

(mode-line-toggle-read-only) (mode-line-toggle-modified, mode-line-widen) (mode-line-abbrev-mode, mode-line-auto-fill-mode): New functions. (make-mode-line-mouse2-map): Rewritten. (mode-line-modified, mode-line-format, minor-mode-alist): Use new functions so that C-h k can show something with a doc string.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 06 Nov 2000 16:43:42 +0000
parents 7ea177b4933a
children 89a45bb5ac64
files lisp/bindings.el
diffstat 1 files changed, 53 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/bindings.el	Mon Nov 06 15:53:05 2000 +0000
+++ b/lisp/bindings.el	Mon Nov 06 16:43:42 2000 +0000
@@ -52,16 +52,55 @@
 This is defined to run function F with no args in the buffer
 corresponding to the mode line clicked."
   (let ((map (make-sparse-keymap)))
-    (define-key map [mode-line mouse-2]
-      `(lambda (e)
-	 (interactive "e")
-	 (save-selected-window
-	   (select-window
-	    (posn-window (event-start e)))
-	   (,f)
-	   (force-mode-line-update))))
+    (define-key map [mode-line mouse-2] f)
     map))
 
+
+(defun mode-line-toggle-read-only (event)
+  "Like `toggle-read-only', for the mode-line."
+  (interactive "e")
+  (save-selected-window
+    (select-window (posn-window (event-start event)))
+    (toggle-read-only)
+    (force-mode-line-update)))
+
+
+(defun mode-line-toggle-modified (event)
+  "Toggle the buffer-modified flag from the mode-line."
+  (interacive "e")
+  (save-selected-window
+    (select-window (posn-window (event-start event)))
+    (set-buffer-modified-p (not (buffer-modified-p)))
+    (force-mode-line-update)))
+
+
+(defun mode-line-widen (event)
+  "Widen a buffer from the mode-line."
+  (interacive "e")
+  (save-selected-window
+    (select-window (posn-window (event-start event)))
+    (widen)
+    (force-mode-line-update)))
+
+
+(defun mode-line-abbrev-mode (event)
+  "Turn off `abbrev-mode' from the mode-line."
+  (interacive "e")
+  (save-selected-window
+    (select-window (posn-window (event-start event)))
+    (abbrev-mode)
+    (force-mode-line-update)))
+
+
+(defun mode-line-auto-fill-mode (event)
+  "Turn off `auto-fill-mode' from the mode-line."
+  (interacive "e")
+  (save-selected-window
+    (select-window (posn-window (event-start event)))
+    (auto-fill-mode)
+    (force-mode-line-update)))
+
+
 (defvar mode-line-input-method-map
   (let ((map (make-sparse-keymap)))
     (define-key map [mode-line mouse-2]
@@ -143,7 +182,8 @@
 					  (if buffer-read-only
 					      "R"
 					    "Not r")))))
-	 'local-map (purecopy (make-mode-line-mouse2-map #'toggle-read-only)))
+	 'local-map (purecopy (make-mode-line-mouse2-map
+			       #'mode-linetoggle-read-only)))
 	(propertize
 	 "%1+"
 	 'help-echo  (purecopy (lambda (window object point)
@@ -154,10 +194,7 @@
 					     "M"
 					   "Not m")))))
 	 'local-map (purecopy (make-mode-line-mouse2-map
-			       (lambda ()
-				 (interactive)
-				 (set-buffer-modified-p
-				  (not (buffer-modified-p))))))))
+			       #'mode-line-toggle-modified))))
   "Mode-line control for displaying whether current buffer is modified.")
 
 (make-variable-buffer-local 'mode-line-modified)
@@ -182,7 +219,7 @@
      (propertize "   %[(" 'help-echo help-echo)
      '(:eval (mode-line-mode-name)) 'mode-line-process 'minor-mode-alist
      (propertize "%n" 'help-echo "mouse-2: widen"
-		 'local-map (make-mode-line-mouse2-map #'widen))
+		 'local-map (make-mode-line-mouse2-map #'mode-line-widen))
      (propertize ")%]--" 'help-echo help-echo)
      `(which-func-mode ("" which-func-format ,dashes))
      `(line-number-mode ("L%l" ,dashes))
@@ -205,14 +242,14 @@
 			 'help-echo (purecopy
 				     "mouse-2: turn off Abbrev mode")
 			 'local-map (purecopy (make-mode-line-mouse2-map
-					       #'abbrev-mode))))
+					       #'mode-line-abbrev-mode))))
        '(overwrite-mode overwrite-mode)
        (list 'auto-fill-function
 	     (propertize " Fill"
 			 'help-echo (purecopy
 				     "mouse-2: turn off Autofill mode")
 			 'local-map (purecopy (make-mode-line-mouse2-map
-					       #'auto-fill-mode))))
+					       #'mode-line-auto-fill-mode))))
        ;; not really a minor mode...
        '(defining-kbd-macro " Def")))