[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scroll-on-drag 263512f18e 2/6: Workaround bug in evil visu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scroll-on-drag 263512f18e 2/6: Workaround bug in evil visual line mode |
Date: |
Sat, 7 Jan 2023 19:59:52 -0500 (EST) |
branch: elpa/scroll-on-drag
commit 263512f18e7260d803c7bca564169404c375d2e4
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Workaround bug in evil visual line mode
Evil visual line mode would scroll back to the original location
after scrolling completed.
The current column was always zero on initialization.
---
scroll-on-drag.el | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/scroll-on-drag.el b/scroll-on-drag.el
index 88338d3950..12cf87f2be 100644
--- a/scroll-on-drag.el
+++ b/scroll-on-drag.el
@@ -143,6 +143,29 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
(run-hooks 'scroll-on-drag-redisplay-hook)
(redisplay)))
+(defun scroll-on-drag--evil-visual-mode-workaround (state)
+ "Workaround for evil-visual line mode, STATE must be \\'pre or \\'post."
+ (when
+ (and
+ (fboundp 'evil-visual-state-p)
+ (funcall 'evil-visual-state-p)
+ (fboundp 'evil-visual-type)
+ (eq (funcall 'evil-visual-type) 'line)
+ (boundp 'evil-visual-point))
+ (let ((mark (symbol-value 'evil-visual-point)))
+ (when (markerp mark)
+ (cond
+ ;; Without this, `point' will be at the beginning of the line
+ ;; (from the pre command hook).
+ ((eq state 'pre)
+ (goto-char (marker-position mark)))
+ ;; Without this, the `point' wont move.
+ ;; See: https://github.com/emacs-evil/evil/issues/1708
+ ((eq state 'post)
+ (set-marker mark (point)))
+ (t
+ (error "Invalid input, internal error")))))))
+
;; ---------------------------------------------------------------------------
;; Public Functions
@@ -428,7 +451,9 @@ Returns true when scrolling took place, otherwise nil."
(when has-scrolled-real
(let ((inhibit-redisplay nil))
(run-hooks 'scroll-on-drag-post-hook)
- (run-window-scroll-functions this-window)))
+ (run-window-scroll-functions this-window))
+
+ (scroll-on-drag--evil-visual-mode-workaround 'post))
;; Result so we know if any scrolling occurred,
;; allowing a fallback action on 'click'.
@@ -444,6 +469,9 @@ when `scroll-on-drag-follow-mouse' is non-nil."
(when scroll-on-drag-follow-mouse
(setq scroll-win (posn-window (or (event-start event)
last-input-event))))
+ ;; Typically moving the point is _not_ ok, however we know the post hook
will handle this.
+ ;; in the case of evil visual line mode.
+ (scroll-on-drag--evil-visual-mode-workaround 'pre)
(cond
(scroll-win
(with-selected-window scroll-win (scroll-on-drag-impl)))
- [nongnu] elpa/scroll-on-drag updated (01c14f4c02 -> b9541a601b), ELPA Syncer, 2023/01/07
- [nongnu] elpa/scroll-on-drag 5eecc1fab2 1/6: Correct URL, ELPA Syncer, 2023/01/07
- [nongnu] elpa/scroll-on-drag a8de098705 3/6: readme: minor updates & clarifications, ELPA Syncer, 2023/01/07
- [nongnu] elpa/scroll-on-drag 263512f18e 2/6: Workaround bug in evil visual line mode,
ELPA Syncer <=
- [nongnu] elpa/scroll-on-drag 99c392995a 5/6: Cleanup: use emacs native formatting, ELPA Syncer, 2023/01/07
- [nongnu] elpa/scroll-on-drag b9541a601b 6/6: Cleanup: function quotes, ELPA Syncer, 2023/01/07
- [nongnu] elpa/scroll-on-drag 130c8aff62 4/6: Cleanup: improve logic for evil-mode workaround, ELPA Syncer, 2023/01/07