Skip to content

Commit 2fd8c16

Browse files
committed
Use show/hide
1 parent 1434fe1 commit 2fd8c16

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

auto-scroll-bar.el

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@
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-
6860
;;
6961
;; (@* "Util" )
7062
;;
@@ -123,7 +115,12 @@
123115

124116
(defun auto-scroll-bar--update (win show-v show-h &optional persistent)
125117
"Update scrollbar WIN, SHOW-V, SHOW-H, PERSISTENT."
126-
(set-window-scroll-bars win nil show-v nil show-h persistent)
118+
;;(set-window-scroll-bars win nil show-v nil show-h persistent)
119+
(let* ((bars (window-scroll-bars win))
120+
(shown-v (nth 2 bars))
121+
(shown-h (nth 5 bars)))
122+
(when (or (not (eq shown-v show-v)) (not (eq shown-h show-h)))
123+
(set-window-scroll-bars win nil show-v nil show-h persistent)))
127124
(save-window-excursion (ignore-errors (enlarge-window 1)))) ; refresh
128125

129126
(defun auto-scroll-bar--show-hide (win)
@@ -135,16 +132,10 @@
135132
(show-h (auto-scroll-bar--show-h-p)))
136133
(auto-scroll-bar--update win show-v show-h)))))
137134

138-
(defun auto-scroll-bar--start-task ()
139-
""
140-
(auto-scroll-bar--with-no-redisplay
141-
(dolist (win (window-list)) (auto-scroll-bar--show-hide win))))
142-
143135
(defun auto-scroll-bar--change (&rest _)
144136
"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)))
137+
(auto-scroll-bar--with-no-redisplay
138+
(dolist (win (window-list)) (auto-scroll-bar--show-hide win))))
148139

149140
(defun auto-scroll-bar--enable ()
150141
"Enable function `auto-scroll-bar-mode'."

0 commit comments

Comments
 (0)