emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/multiple-cursors dce6c00 174/434: Add mc/cursor-specific-v


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors dce6c00 174/434: Add mc/cursor-specific-vars to handle vars that need to be tracked per cursor.
Date: Sat, 7 Aug 2021 09:20:20 -0400 (EDT)

branch: elpa/multiple-cursors
commit dce6c00fab0c27ac520440f3a9eb391b624a5437
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Add mc/cursor-specific-vars to handle vars that need to be tracked per 
cursor.
    
     - also add autopair-vars to this list.
    
    Fixes #32
---
 multiple-cursors-core.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 4a66ca6..0a430ff 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -118,6 +118,17 @@ highlights the entire width of the window."
     (overlay-put overlay 'type 'additional-region)
     overlay))
 
+(defvar mc/cursor-specific-vars '(autopair-action
+                                  autopair-wrap-action
+                                  er/history)
+  "A list of vars that need to be tracked on a per-cursor basis.")
+
+(defun mc/store-cursor-specific-var (var)
+  (when (boundp var) (overlay-put o var (eval var))))
+
+(defun mc/restore-cursor-specific-var (var)
+  (when (boundp var) (set var (overlay-get o var))))
+
 (defun mc/store-current-state-in-overlay (o)
   "Store relevant info about point and mark in the given overlay."
   (overlay-put o 'point (set-marker (make-marker) (point)))
@@ -128,7 +139,7 @@ highlights the entire width of the window."
   (overlay-put o 'mark-active mark-active)
   (overlay-put o 'yank-undo-function yank-undo-function)
   (overlay-put o 'kill-ring-yank-pointer kill-ring-yank-pointer)
-  (when (boundp 'er/history) (overlay-put o 'er/history er/history))
+  (mapc 'mc/store-cursor-specific-var mc/cursor-specific-vars)
   o)
 
 (defun mc/restore-state-from-overlay (o)
@@ -141,7 +152,7 @@ highlights the entire width of the window."
   (setq mark-active (overlay-get o 'mark-active))
   (setq yank-undo-function (overlay-get o 'yank-undo-function))
   (setq kill-ring-yank-pointer (overlay-get o 'kill-ring-yank-pointer))
-  (when (boundp 'er/history) (setq er/history (overlay-get o 'er/history))))
+  (mapc 'mc/restore-cursor-specific-var mc/cursor-specific-vars))
 
 (defun mc/remove-fake-cursor (o)
   "Delete overlay with state, including dependent overlays and markers."
@@ -186,6 +197,7 @@ Saves the current state in the overlay to be restored 
later."
   (run-hooks 'pre-command-hook)
   (unless (eq this-command 'ignore)
     (call-interactively cmd))
+  (run-hooks 'post-command-hook)
   (when deactivate-mark (deactivate-mark)))
 
 (defvar mc--executing-command-for-fake-cursor nil)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]