changeset 97437:c7a00c2c8219

(visual-line--saved-state): New var. (visual-line-mode): Save local values of variables, and restore them when visual-line-mode is disabled.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 12 Aug 2008 19:39:50 +0000
parents 4b240c36264c
children 1d048637d408
files lisp/simple.el
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Tue Aug 12 19:38:05 2008 +0000
+++ b/lisp/simple.el	Tue Aug 12 19:39:50 2008 +0000
@@ -4508,6 +4508,8 @@
 			    (copy-tree fringe-indicator-alist)))))))
 	 (set-default symbol value)))
 
+(defvar visual-line--saved-state nil)
+
 (define-minor-mode visual-line-mode
   "Redefine simple editing commands to act on visual lines, not logical lines.
 This also turns on `word-wrap' in the buffer."
@@ -4516,6 +4518,15 @@
   :lighter " wrap"
   (if visual-line-mode
       (progn
+	(set (make-local-variable 'visual-line--saved-state) nil)
+	;; Save the local values of some variables, to be restored if
+	;; visual-line-mode is turned off.
+	(dolist (var '(line-move-visual truncate-lines
+		       truncate-partial-width-windows
+		       word-wrap fringe-indicator-alist))
+	  (if (local-variable-p var)
+	      (push (cons var (symbol-value var)) 
+		    visual-line--saved-state)))
 	(set (make-local-variable 'line-move-visual) t)
 	(set (make-local-variable 'truncate-partial-width-windows) nil)
 	(setq truncate-lines nil
@@ -4527,7 +4538,10 @@
     (kill-local-variable 'word-wrap)
     (kill-local-variable 'truncate-lines)
     (kill-local-variable 'truncate-partial-width-windows)
-    (kill-local-variable 'fringe-indicator-alist)))
+    (kill-local-variable 'fringe-indicator-alist)
+    (dolist (saved visual-line--saved-state)
+      (set (make-local-variable (car saved)) (cdr saved)))
+    (kill-local-variable 'visual-line--saved-state)))
 
 (defun turn-on-visual-line-mode ()
   (visual-line-mode 1))