5353 :group 'auto-scroll-bar )
5454
5555(defcustom auto-scroll-bar-hide-minibuffer t
56- " List of buffers to disable the scroll bar completely ."
56+ " Non-nil to hide scrollbar in minibuffer ."
5757 :type 'boolean
5858 :group 'auto-scroll-bar )
5959
7171 (declare (indent 0 ) (debug t ))
7272 `(let ((inhibit-redisplay t )
7373 (inhibit-modification-hooks t )
74- (inhibit-point-motion-hooks t )
7574 after-focus-change-function
7675 buffer-list-update-hook
7776 display-buffer-alist
8382
8483(defun auto-scroll-bar--window-width ()
8584 " Calculate inner window width."
86- (let ((width (window-width )))
87- (when (bound-and-true-p display-line-numbers-mode)
88- (cl-decf width (line-number-display-width )))
89- (when vertical-scroll-bar
90- (cl-decf width (scroll-bar-columns (get-scroll-bar-mode ))))
91- width))
85+ (window-max-chars-per-line ))
9286
9387(defun auto-scroll-bar--window-height ()
9488 " Calculate inner window height."
114108 truncate-lines
115109 (save-excursion
116110 (move-to-window-line 0 )
117- (let ((count 0 ) (target (auto-scroll-bar--window-height)) break)
111+ (let* ((win-w (auto-scroll-bar--window-width))
112+ (win-h (auto-scroll-bar--window-height))
113+ (count 0 ) (target win-h) break)
118114 (while (and (not (eobp )) (< count target) (not break))
119- (if (< (auto-scroll-bar--window-width) (- (line-end-position ) (line-beginning-position )))
115+ (if (< win-w (- (line-end-position ) (line-beginning-position )))
120116 (setq break t )
121117 (forward-line 1 )
122118 (cl-incf count)))
@@ -141,7 +137,7 @@ and SHOW-H."
141137 " Update scrollbar WIN, SHOW-V, SHOW-H, PERSISTENT."
142138 (when (auto-scroll-bar--toggle-p win show-v show-h)
143139 (set-window-scroll-bars win nil show-v nil show-h persistent)
144- (save-window-excursion (ignore-errors (enlarge- window 1 ))))) ; refresh
140+ (save-window-excursion (ignore-errors (window-resize win 0 ))))) ; refresh
145141
146142(defun auto-scroll-bar--show-hide (win )
147143 " Show/Hide scroll-bar for WIN."
@@ -152,16 +148,16 @@ and SHOW-H."
152148 (show-h (auto-scroll-bar--show-h-p)))
153149 (auto-scroll-bar--update win show-v show-h)))))
154150
155- (defun auto-scroll-bar--hide-minibuffer ()
151+ (defun auto-scroll-bar--hide-minibuffer (&optional frame )
156152 " Hide minibuffer when variable `auto-scroll-bar-hide-minibuffer' is enabled."
157153 (when auto-scroll-bar-hide-minibuffer
158- (auto-scroll-bar--update (minibuffer-window ) nil nil t )))
154+ (auto-scroll-bar--update (minibuffer-window frame ) nil nil t )))
159155
160- (defun auto-scroll-bar--size-change (&rest _ )
156+ (defun auto-scroll-bar--size-change (&optional frame & rest _ )
161157 " Show/Hide all visible windows."
162158 (auto-scroll-bar--with-no-redisplay
163- (dolist (win (window-list )) (auto-scroll-bar--show-hide win))
164- (auto-scroll-bar--hide-minibuffer)))
159+ (dolist (win (window-list frame )) (auto-scroll-bar--show-hide win))
160+ (auto-scroll-bar--hide-minibuffer frame )))
165161
166162(defun auto-scroll-bar--scroll (&optional window &rest _ )
167163 " Show/Hide scroll-bar on WINDOW."
@@ -187,7 +183,7 @@ and SHOW-H."
187183
188184;;;### autoload
189185(define-minor-mode auto-scroll-bar-mode
190- " Minor mode ' auto-scroll-bar-mode'."
186+ " Minor mode ` auto-scroll-bar-mode' ."
191187 :global t
192188 :require 'auto-scroll-bar-mode
193189 :group 'auto-scroll-bar
0 commit comments