|
57 | 57 | :type 'boolean |
58 | 58 | :group 'auto-scroll-bar) |
59 | 59 |
|
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 | | - |
68 | 60 | ;; |
69 | 61 | ;; (@* "Util" ) |
70 | 62 | ;; |
|
123 | 115 |
|
124 | 116 | (defun auto-scroll-bar--update (win show-v show-h &optional persistent) |
125 | 117 | "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))) |
127 | 124 | (save-window-excursion (ignore-errors (enlarge-window 1)))) ; refresh |
128 | 125 |
|
129 | 126 | (defun auto-scroll-bar--show-hide (win) |
|
135 | 132 | (show-h (auto-scroll-bar--show-h-p))) |
136 | 133 | (auto-scroll-bar--update win show-v show-h))))) |
137 | 134 |
|
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 | | - |
143 | 135 | (defun auto-scroll-bar--change (&rest _) |
144 | 136 | "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)))) |
148 | 139 |
|
149 | 140 | (defun auto-scroll-bar--enable () |
150 | 141 | "Enable function `auto-scroll-bar-mode'." |
|
0 commit comments