]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix restoring data in visual-line-mode
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 1 Oct 2020 16:49:45 +0000 (18:49 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 1 Oct 2020 16:49:45 +0000 (18:49 +0200)
* lisp/simple.el (visual-line-mode): Only save values once, even
if the mode is switched on twice (bug#43730).  This makes both
previously set local values for variables like truncate-lines, as
well as default values for truncate-lines restorable.

* lisp/emulation/cua-base.el (cua-mode): Ditto.

lisp/emulation/cua-base.el
lisp/simple.el

index c4dcb76446efc6946be672ef5be906d0d52277cb..926305e60777a354e793eaf03db4028f37662c76 100644 (file)
@@ -1379,9 +1379,10 @@ the prefix fallback behavior."
 
   (cond
    (cua-mode
-    (setq cua--saved-state
-         (list
-          (and (boundp 'delete-selection-mode) delete-selection-mode)))
+    (unless cua--saved-state
+      (setq cua--saved-state
+           (list
+            (and (boundp 'delete-selection-mode) delete-selection-mode))))
     (if cua-delete-selection
         (delete-selection-mode 1)
       (if (and (boundp 'delete-selection-mode) delete-selection-mode)
index fef22c2fa6f648585992799c1345c97e1d56319c..05a74d90d62076649715c7681deafc6a21d0d4ce 100644 (file)
@@ -7275,15 +7275,16 @@ Mode' for details."
   :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)))
+        (unless visual-line--saved-state
+         (setq-local visual-line--saved-state (list 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
@@ -7297,7 +7298,8 @@ Mode' for details."
     (kill-local-variable 'truncate-partial-width-windows)
     (kill-local-variable 'fringe-indicator-alist)
     (dolist (saved visual-line--saved-state)
-      (set (make-local-variable (car saved)) (cdr saved)))
+      (when (car saved)
+        (set (make-local-variable (car saved)) (cdr saved))))
     (kill-local-variable 'visual-line--saved-state)))
 
 (defun turn-on-visual-line-mode ()