add iscroll and change vertical scroll bar configuration

This commit is contained in:
2021-02-13 13:12:55 +01:00
parent 05bee89af1
commit 09e44e084b
3 changed files with 336 additions and 43 deletions

View File

@@ -46,49 +46,26 @@
;; `scroll-bar-mode' sets for all frames and all windows
;; use `set-window-scroll-bars' for windows only
(scroll-bar-mode 0) ;; 1st deactivate scrolling
(add-hook 'visual-line-mode-hook 'my-visual-line-mode-hook)
(defun my-visual-line-mode-hook ()
"no `horizontal-scroll-bar' if `visual-line-mode'"
(if visual-line-mode
(set-window-scroll-bars (frame-selected-window) nil t nil nil)
(set-window-scroll-bars (frame-selected-window) nil t nil 'bottom)
))
(add-hook 'window-state-change-hook
(lambda () (my-window-state-change (window-buffer))))
(defun my-window-state-change (frame-or-window)
(let (window
(vertical-type nil)
(horizontal-type nil)
buffer
buffer-name)
(when (framep frame-or-window)
(setq window (frame-selected-window frame-or-window)))
(setq buffer (window-buffer window))
(setq buffer-name (buffer-name buffer))
;; turn scrolling on
(when visual-line-mode
(setq vertical-type 'right)
(setq horizontal-type nil))
(when truncate-lines
(setq vertical-type 'right)
(setq horizontal-type 'bottom))
;; turn off
(cond
((or (minibufferp buffer)
(string-equal major-mode "doc-view-mode")
(string-equal buffer-name " *Org tags*"))
(setq vertical-type nil)
(setq horizontal-type nil))
((string-prefix-p "*mu4e" buffer-name)
(setq vertical-type 'right)))
;; (message "%s %s %s %s %s"
;; buffer-name
;; visual-line-mode
;; truncate-lines
;; vertical-type
;; horizontal-type)
(set-window-scroll-bars window nil vertical-type nil horizontal-type)))
)
(defun my-window-scroll-function (window display-start)
"This function
- is listed in `window-scroll-functions' which is called by
`set-window-buffer' before running `window-configuration-change-hook'
and therefore will be run on every vertical scroll event
- will activate vertical scoll bar if not whole buffer height is
visible
WINDOW: `window' object, its string will look like #<window 3 on gui-settings.el> and
DISPLAY-START: `integer', e.g. 3820"
;; (message "%s" window)
(let ((vertical-type nil)
(horizontal-type nil))
(unless (string-equal (format-mode-line "%p") "All")
(setq vertical-type 'right))
;; `scroll-bar-mode' not used bc/ it's global, therefore:
(set-window-scroll-bars
window nil vertical-type nil horizontal-type nil)))
(add-to-list 'window-scroll-functions #'my-window-scroll-function)
) ;; end of use-package emacs
(use-package tab-bar
:defer 0.5
@@ -471,6 +448,9 @@ See also `dashboard-insert-section'."
:commands focus-mode
:custom-face (focus-unfocused ((t :inherit shadow))))
(use-package iscroll
:hook ((special-mode text-mode) . iscroll-mode))
(use-package virtual-auto-fill
:delight (virtual-auto-fill-mode "Ⓥf")
:commands virtual-auto-fill-mode