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

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

[nongnu] elpa/scroll-on-drag 179c2acecc: Fix scrolling resetting the goa


From: ELPA Syncer
Subject: [nongnu] elpa/scroll-on-drag 179c2acecc: Fix scrolling resetting the goal-column
Date: Mon, 13 Mar 2023 02:02:23 -0400 (EDT)

branch: elpa/scroll-on-drag
commit 179c2acecc48d3ceca4b449b2a225d684002bb32
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix scrolling resetting the goal-column
    
    Support goal-column & temporary-goal-column.
---
 scroll-on-drag.el | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/scroll-on-drag.el b/scroll-on-drag.el
index ed75785020..bc36c7e042 100644
--- a/scroll-on-drag.el
+++ b/scroll-on-drag.el
@@ -255,7 +255,20 @@ Returns true when scrolling took place, otherwise nil."
             nil)))
 
          ;; Restore indent (lost when scrolling).
-         (restore-column (current-column))
+         (this-column (current-column))
+         ;; Restore column (may be nil.)
+         (restore-column
+          (or goal-column
+              (cond
+               ((and temporary-goal-column
+                     (memq last-command (list 'next-line 'previous-line 
'line-move)))
+                (cond
+                 ((consp temporary-goal-column)
+                  (car temporary-goal-column))
+                 (t
+                  temporary-goal-column)))
+               (t
+                nil))))
 
          (mouse-y-fn
           (cond
@@ -457,8 +470,14 @@ Returns true when scrolling took place, otherwise nil."
       (setq has-scrolled nil))
 
     ;; Restore indent level if possible.
-    (when (and has-scrolled (> restore-column 0))
-      (move-to-column restore-column))
+    (when has-scrolled
+      (unless restore-column
+        (setq temporary-goal-column this-column)
+        (setq restore-column this-column))
+      (when (> restore-column 0)
+        (move-to-column restore-column))
+      ;; Needed so `temporary-goal-column' is respected in the future.
+      (setq this-command 'line-move))
 
     (when has-scrolled-real
       (let ((inhibit-redisplay nil))



reply via email to

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