[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scroll-on-drag 9836df8c62 1/2: Add scroll-on-drag-mode-lin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scroll-on-drag 9836df8c62 1/2: Add scroll-on-drag-mode-line-format to optionally override the mode-line |
Date: |
Sun, 22 Jan 2023 04:02:00 -0500 (EST) |
branch: elpa/scroll-on-drag
commit 9836df8c628d2b496ca62cf37d3a029af819bc11
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Add scroll-on-drag-mode-line-format to optionally override the mode-line
This can be used to prevent complex mode-lines interfering with
scrolling performance.
---
readme.rst | 4 ++++
scroll-on-drag.el | 22 ++++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/readme.rst b/readme.rst
index 070b5d98c4..5b9f0bfe34 100644
--- a/readme.rst
+++ b/readme.rst
@@ -93,3 +93,7 @@ While the defaults seem to work well, these values can be
customized.
``scroll-on-drag-follow-mouse``
When non-nil, scroll the window under the mouse cursor (even when it's not
active)
returning focus on completion.
+``scroll-on-drag-mode-line-format``: nil
+ When non-nil, use this value for the ``mode-line-format`` while scrolling.
+ This can be used to temporarily override the mode-line while scrolling.
+ It can also help to avoid overly complex mode-lines from slowing down
scrolling.
diff --git a/scroll-on-drag.el b/scroll-on-drag.el
index 2df1bfca61..19e466921e 100644
--- a/scroll-on-drag.el
+++ b/scroll-on-drag.el
@@ -72,6 +72,13 @@
"Scroll the window under the mouse cursor (instead of the current active
window)."
:type 'boolean)
+(defcustom scroll-on-drag-mode-line-format nil
+ "The `mode-line-format' to use or nil to leave the `mode-line-format'
unchanged.
+
+This can be useful to use a simplified or event disabling the mode-line
+while scrolling, as a complex mode-line can interfere with smooth scrolling."
+ :type '(choice (const nil) string))
+
(defcustom scroll-on-drag-pre-hook nil
"List of functions to be called when `scroll-on-drag' starts."
:type 'hook)
@@ -476,14 +483,25 @@ This requires a separate code path to run pre/post logic."
(t
(scroll-on-drag--impl)))))
+(defun scroll-on-drag--impl-with-mode-line-format ()
+ "Call `mode-line-format' with mode-line override."
+
+ (cond
+ (scroll-on-drag-mode-line-format
+ (prog1 (let ((mode-line-format scroll-on-drag-mode-line-format))
+ (scroll-on-drag--impl-with-evil-mode-workaround))
+ (force-mode-line-update)))
+ (t
+ (scroll-on-drag--impl-with-evil-mode-workaround))))
+
(defun scroll-on-drag--impl-with-window (scroll-win)
"Scroll on drag function that takes an optional SCROLL-WIN."
(cond
(scroll-win
(with-selected-window scroll-win
- (scroll-on-drag--impl-with-evil-mode-workaround)))
+ (scroll-on-drag--impl-with-mode-line-format)))
(t
- (scroll-on-drag--impl-with-evil-mode-workaround))))
+ (scroll-on-drag--impl-with-mode-line-format))))
(defun scroll-on-drag (&optional event)
"Main scroll on drag function.