Skip to content

Commit aee9a9a

Browse files
committed
Update delay
1 parent f99922a commit aee9a9a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

auto-scroll-bar.el

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
:type 'boolean
5858
:group 'auto-scroll-bar)
5959

60+
(defcustom auto-scroll-bar-delay 0.2
61+
"Time to update scroll-bars state."
62+
:type 'float
63+
:group 'auto-scroll-bar)
64+
65+
(defvar auto-scroll-bar--timer nil
66+
"Timer to do the show/hide task.")
67+
6068
;;
6169
;; (@* "Util" )
6270
;;
@@ -127,11 +135,17 @@
127135
(show-h (auto-scroll-bar--show-h-p)))
128136
(auto-scroll-bar--update win show-v show-h)))))
129137

130-
(defun auto-scroll-bar--change (&rest _)
131-
"Window state change."
138+
(defun auto-scroll-bar--start-task ()
139+
""
132140
(auto-scroll-bar--with-no-redisplay
133141
(dolist (win (window-list)) (auto-scroll-bar--show-hide win))))
134142

143+
(defun auto-scroll-bar--change (&rest _)
144+
"Window state change."
145+
(when (timerp auto-scroll-bar--timer) (cancel-timer auto-scroll-bar--timer))
146+
(setq auto-scroll-bar--timer
147+
(run-with-idle-timer auto-scroll-bar-delay nil #'auto-scroll-bar--start-task)))
148+
135149
(defun auto-scroll-bar--enable ()
136150
"Enable function `auto-scroll-bar-mode'."
137151
(add-hook 'post-command-hook #'auto-scroll-bar--change) ; post command, less buggy

0 commit comments

Comments
 (0)