Function: tpu-set-scroll-margins
tpu-set-scroll-margins is an autoloaded, interactive and byte-compiled
function defined in tpu-extras.el.gz.
Signature
(tpu-set-scroll-margins TOP BOTTOM &optional EMIT-MSG)
Documentation
Set scroll margins.
Key Bindings
Aliases
SET SCROLL MARGINS
set scroll margins
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/tpu-extras.el.gz
;;; Function to set scroll margins
;;;###autoload
(defun tpu-set-scroll-margins (top bottom &optional emit-msg)
"Set scroll margins."
(interactive
"sEnter top scroll margin (N lines or N%% or RETURN for current value): \
\nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): \
\np")
;; set top scroll margin
(or (string= top "")
(setq tpu-top-scroll-margin
(if (string= "%" (substring top -1))
(string-to-number top)
(/ (1- (+ (* (string-to-number top) 100) (window-height)))
(window-height)))))
;; set bottom scroll margin
(or (string= bottom "")
(setq tpu-bottom-scroll-margin
(if (string= "%" (substring bottom -1))
(string-to-number bottom)
(/ (1- (+ (* (string-to-number bottom) 100) (window-height)))
(window-height)))))
(dolist (f '(newline newline-and-indent do-auto-fill))
(advice-add f :around #'tpu--respect-bottom-scroll-margin))
;; report scroll margin settings if running interactively
(and emit-msg
(message "Scroll margins set. Top = %s%%, Bottom = %s%%"
tpu-top-scroll-margin tpu-bottom-scroll-margin)))