Skip to content

Commit 33f97fb

Browse files
authored
Merge pull request #1 from jcs-elpa/feature/realtime
feature: Function show/hide in editing
2 parents 8434d5e + bc53e19 commit 33f97fb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1212
* Fix when truncate lines disabled (dd966bb9b0b858d028c0af7399f6edba1d22c450)
1313
* Don't enable inside terminal (8bda044ad7b741abc239b9df177e65ad0f969ea9)
1414
* Fix show horizontal scroll bar's logic (afda338ccd67456142361be610a6bdd7e2360143)
15+
* Function show/hide in editing (#1)
1516

1617
## 0.1.0
1718
> Released Mar 02, 2022

auto-scroll-bar.el

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ and SHOW-H."
149149
(auto-scroll-bar--update win show-v show-h)))))
150150

151151
(defun auto-scroll-bar--hide-minibuffer (&optional frame)
152-
"Hide minibuffer when variable `auto-scroll-bar-hide-minibuffer' is enabled."
152+
"Hide minibuffer when variable `auto-scroll-bar-hide-minibuffer' is enabled.
153+
154+
Optional argument FRAME is used to select frame's minibuffer."
153155
(when auto-scroll-bar-hide-minibuffer
154156
(auto-scroll-bar--update (minibuffer-window frame) nil nil t)))
155157

156158
(defun auto-scroll-bar--size-change (&optional frame &rest _)
157-
"Show/Hide all visible windows."
159+
"Show/Hide all visible windows in FRAME."
158160
(auto-scroll-bar--with-no-redisplay
159161
(dolist (win (window-list frame)) (auto-scroll-bar--show-hide win))
160162
(auto-scroll-bar--hide-minibuffer frame)))
@@ -164,11 +166,18 @@ and SHOW-H."
164166
(auto-scroll-bar--with-no-redisplay
165167
(when (windowp window) (auto-scroll-bar--show-hide window))))
166168

169+
(defun auto-scroll-bar--after-change (&rest _)
170+
"After change hook."
171+
(when-let ((current (selected-window)))
172+
(if (equal (minibuffer-window) current) (auto-scroll-bar--hide-minibuffer)
173+
(auto-scroll-bar--scroll current))))
174+
167175
(defun auto-scroll-bar--enable ()
168176
"Enable function `auto-scroll-bar-mode'."
169177
(cond ((display-graphic-p)
170178
(add-hook 'window-size-change-functions #'auto-scroll-bar--size-change)
171179
(add-hook 'window-scroll-functions #'auto-scroll-bar--scroll)
180+
(add-hook 'after-change-functions #'auto-scroll-bar--after-change)
172181
(toggle-scroll-bar 1)
173182
(when auto-scroll-bar-horizontal (toggle-horizontal-scroll-bar 1))
174183
(auto-scroll-bar--size-change)) ; execute once
@@ -178,6 +187,7 @@ and SHOW-H."
178187
"Disable function `auto-scroll-bar-mode'."
179188
(remove-hook 'window-size-change-functions #'auto-scroll-bar--size-change)
180189
(remove-hook 'window-scroll-functions #'auto-scroll-bar--scroll)
190+
(remove-hook 'after-change-functions #'auto-scroll-bar--after-change)
181191
(toggle-scroll-bar -1)
182192
(toggle-horizontal-scroll-bar -1))
183193

0 commit comments

Comments
 (0)