[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/topspace 1049ef1b0e 019/181: Make topspace-enable and t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/topspace 1049ef1b0e 019/181: Make topspace-enable and topspace-disable private functions |
Date: |
Tue, 23 Aug 2022 12:58:29 -0400 (EDT) |
branch: externals/topspace
commit 1049ef1b0efb14c7e9b119f4d1da82ca1d29a914
Author: Trevor Pogue <poguete@mcmaster.ca>
Commit: Trevor Pogue <poguete@mcmaster.ca>
Make topspace-enable and topspace-disable private functions
---
topspace.el | 419 ++++++++++++++++++++++++++++++------------------------------
1 file changed, 209 insertions(+), 210 deletions(-)
diff --git a/topspace.el b/topspace.el
index 0e1b5cd0cd..fe11328347 100644
--- a/topspace.el
+++ b/topspace.el
@@ -54,31 +54,31 @@
;;; Customization
(defgroup topspace nil
- "Scroll above the top line to vertically center top text."
- :group 'scrolling
- :group 'convenience
- :link '(emacs-library-link :tag "Source Lisp File" "topspace.el")
- :link '(url-link "https://github.com/trevorpogue/topspace")
- :link '(emacs-commentary-link :tag "Commentary" "topspace"))
+ "Scroll above the top line to vertically center top text."
+ :group 'scrolling
+ :group 'convenience
+ :link '(emacs-library-link :tag "Source Lisp File" "topspace.el")
+ :link '(url-link "https://github.com/trevorpogue/topspace")
+ :link '(emacs-commentary-link :tag "Commentary" "topspace"))
(defcustom topspace-autocenter-buffers
- t
- "Vertically center small buffers when first opened or window sizes
change."
- :group 'topspace
- :type 'boolean)
+ t
+ "Vertically center small buffers when first opened or window sizes change."
+ :group 'topspace
+ :type 'boolean)
(defcustom topspace-center-position
- 0.5
- "Suggested position when centering buffers as a ratio of frame height.
+ 0.5
+ "Suggested position when centering buffers as a ratio of frame height.
A value from 0 to 1 where lower values center buffers higher up in the screen.
Used in `topspace-recenter-buffer' when called or when opening/resizing buffers
if `topspace-autocenter-buffers' is non-nil."
- :group 'topspace
- :type 'float)
+ :group 'topspace
+ :type 'float)
(defcustom topspace-mode-line " T"
- "Mode line lighter for Topspace.
+ "Mode line lighter for Topspace.
The value of this variable is a mode line template as in
`mode-line-format'. See Info Node `(elisp)Mode Line Format' for
@@ -86,43 +86,48 @@ more information. Note that it should contain a _single_
mode
line construct only.
Set this variable to nil to disable the mode line completely."
- :group 'topspace
- :type 'sexp)
+ :group 'topspace
+ :type 'sexp)
+
+(defvar topspace-keymap (make-sparse-keymap)
+ "Keymap for Topspace commands.
+By default this is left empty for users to set with their own
+preferred bindings.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Advice for `scroll-up', `scroll-down', and `recenter'
(defun topspace--scroll (total-lines)
- "Run before `scroll-up'/`scroll-down' for scrolling above the top line.
+ "Run before `scroll-up'/`scroll-down' for scrolling above the top line.
TOTAL-LINES is used in the same way as in `scroll-down'."
- (let ((old-topspace-height (topspace--height))
- (new-topspace-height))
- (setq new-topspace-height (topspace--correct-height
-
(+ old-topspace-height total-lines)))
- (setq topspace--window-start-before-scroll (window-start))
- (topspace--put new-topspace-height)
- (- total-lines (- new-topspace-height old-topspace-height))))
+ (let ((old-topspace-height (topspace--height))
+ (new-topspace-height))
+ (setq new-topspace-height (topspace--correct-height
+ (+ old-topspace-height total-lines)))
+ (setq topspace--window-start-before-scroll (window-start))
+ (topspace--put new-topspace-height)
+ (- total-lines (- new-topspace-height old-topspace-height))))
(defun topspace--filter-args-scroll-down (&optional total-lines)
- "Run before `scroll-down' for scrolling above the top line.
+ "Run before `scroll-down' for scrolling above the top line.
TOTAL-LINES is used in the same way as in `scroll-down'."
- (setq total-lines (car total-lines))
- (setq total-lines (or total-lines (- (topspace--window-height)
-
next-screen-context-lines)))
- (setq topspace--total-lines-scrolling total-lines)
- (list (topspace--scroll total-lines)))
+ (setq total-lines (car total-lines))
+ (setq total-lines (or total-lines (- (topspace--window-height)
+ next-screen-context-lines)))
+ (setq topspace--total-lines-scrolling total-lines)
+ (list (topspace--scroll total-lines)))
(defun topspace--filter-args-scroll-up (&optional total-lines)
- "Run before `scroll-up' for scrolling above the top line.
+ "Run before `scroll-up' for scrolling above the top line.
TOTAL-LINES is used in the same way as in `scroll-up'."
- (setq total-lines (car total-lines))
- (setq total-lines (* (or total-lines (- (topspace--window-height)
-
next-screen-context-lines)) -1))
- (setq topspace--total-lines-scrolling total-lines)
- (list (* (topspace--scroll total-lines) -1)))
+ (setq total-lines (car total-lines))
+ (setq total-lines (* (or total-lines (- (topspace--window-height)
+ next-screen-context-lines)) -1))
+ (setq topspace--total-lines-scrolling total-lines)
+ (list (* (topspace--scroll total-lines) -1)))
(defun topspace--after-scroll (&optional total-lines)
- "Run after `scroll-up'/`scroll-down' for scrolling above the top line.
+ "Run after `scroll-up'/`scroll-down' for scrolling above the top line.
TOTAL-LINES is used in the same way as in `scroll-down'.
This is needed when scrolling down (moving buffer text lower in the screen)
@@ -130,211 +135,212 @@ and no top space was present before scrolling but it
should be after scrolling.
The reason this is needed is because `topspace--put' only draws the overlay
when
`window-start` equals 1, which can only be true after the scroll command is run
in the described case above."
- (setq total-lines topspace--total-lines-scrolling)
- (when (and (> topspace--window-start-before-scroll 1) (= (window-start)
1))
- (let ((lines-already-scrolled (topspace--count-lines
-
1
topspace--window-start-before-scroll)))
- (setq total-lines (abs total-lines))
- (set-window-start (selected-window) 1)
- (topspace--put (- total-lines
lines-already-scrolled)))))
+ (setq total-lines topspace--total-lines-scrolling)
+ (when (and (> topspace--window-start-before-scroll 1) (= (window-start) 1))
+ (let ((lines-already-scrolled (topspace--count-lines
+ 1 topspace--window-start-before-scroll)))
+ (setq total-lines (abs total-lines))
+ (set-window-start (selected-window) 1)
+ (topspace--put (- total-lines lines-already-scrolled)))))
(defun topspace--after-recenter (&optional line-offset redisplay)
- "Recenter near the top of buffers by adding top space appropriately.
+ "Recenter near the top of buffers by adding top space appropriately.
LINE-OFFSET and REDISPLAY are used in the same way as in `recenter'."
- ;; redisplay is unused but needed since this function
- ;; must take the same arguments as `recenter'
- redisplay ; remove flycheck warning for unused argument (see above)
- (when (= (window-start) 1)
- (unless line-offset
- (setq line-offset (round (/ (topspace--window-height)
line-offset))))
- (when (< line-offset 0)
- (setq line-offset (- (topspace--window-height)
line-offset)))
- (topspace--put (- line-offset (topspace--count-lines
(window-start)
-
(point))))))
+ ;; redisplay is unused but needed since this function
+ ;; must take the same arguments as `recenter'
+ redisplay ; remove flycheck warning for unused argument (see above)
+ (when (= (window-start) 1)
+ (unless line-offset
+ (setq line-offset (round (/ (topspace--window-height) line-offset))))
+ (when (< line-offset 0)
+ (setq line-offset (- (topspace--window-height) line-offset)))
+ (topspace--put (- line-offset (topspace--count-lines (window-start)
+ (point))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Top space line height calculation
(defun topspace--set-height (height)
- "Set the top space line height for the selected window to HEIGHT.
+ "Set the top space line height for the selected window to HEIGHT.
Will only set to HEIGHT if HEIGHT is a valid value based on (window-start)."
- (setf (alist-get (selected-window) topspace--heights)
- (topspace--correct-height height)))
+ (setf (alist-get (selected-window) topspace--heights)
+ (topspace--correct-height height)))
(defun topspace--height ()
- "Get the top space line height for the selected window.
+ "Get the top space line height for the selected window.
If the existing value is invalid, set and return a valid value.
If no previous value exists, return the appropriate value to
center the buffer when `topspace-autocenter-buffers' is non-nil, else 0."
- (let ((height) (window (selected-window)))
- (setq height (alist-get window topspace--heights))
- (unless (or height (topspace--recenter-buffers-p)) (setq height
0))
- (when height (topspace--set-height (topspace--correct-height
height)))
- (when (and (not height) (topspace--recenter-buffers-p))
- (setq height (alist-get (selected-window)
topspace--autocenter-heights))
- (unless height (setq height
(topspace--height-to-make-buffer-centered)))
- (setq height (topspace--correct-height height))
- (setf (alist-get window topspace--heights) height))
- height))
+ (let ((height) (window (selected-window)))
+ (setq height (alist-get window topspace--heights))
+ (unless (or height (topspace--recenter-buffers-p)) (setq height 0))
+ (when height (topspace--set-height (topspace--correct-height height)))
+ (when (and (not height) (topspace--recenter-buffers-p))
+ (setq height (alist-get (selected-window) topspace--autocenter-heights))
+ (unless height (setq height (topspace--height-to-make-buffer-centered)))
+ (setq height (topspace--correct-height height))
+ (setf (alist-get window topspace--heights) height))
+ height))
(defun topspace--correct-height (height)
- "Return HEIGHT if a valid top space line height, else return a valid
value.
+ "Return HEIGHT if a valid top space line height, else return a valid value.
Valid top space line heights are:
- never negative,
- only positive when `window-start' equals 1,
- not larger than `topspace--window-height' minus `next-screen-context-lines'."
- (let ((max-height (- (topspace--window-height)
next-screen-context-lines)))
- (when (> (window-start) 1) (setq height 0))
- (when (< height 0) (setq height 0))
- (when (> height max-height) (setq height max-height)))
- height)
+ (let ((max-height (- (topspace--window-height) next-screen-context-lines)))
+ (when (> (window-start) 1) (setq height 0))
+ (when (< height 0) (setq height 0))
+ (when (> height max-height) (setq height max-height)))
+ height)
(defun topspace--total-lines-past-max (&optional topspace-height)
- "Used when making sure top space height does not push cursor off-screen.
+ "Used when making sure top space height does not push cursor off-screen.
Return how many lines past the bottom of the window the cursor would get pushed
if setting the top space to the suggested value TOPSPACE-HEIGHT.
Any value above 0 flags that the suggested TOPSPACE-HEIGHT is too large."
- (- (topspace--current-line-plus-topspace topspace-height)
- (- (topspace--window-height) next-screen-context-lines)))
+ (- (topspace--current-line-plus-topspace topspace-height)
+ (- (topspace--window-height) next-screen-context-lines)))
(defun topspace--current-line-plus-topspace (&optional topspace-height)
- "Used when making sure top space height does not push cursor off-screen.
+ "Used when making sure top space height does not push cursor off-screen.
Return the current line plus the top space height TOPSPACE-HEIGHT."
- (+ (topspace--count-lines (window-start) (point))
- (or topspace-height (topspace--height))))
+ (+ (topspace--count-lines (window-start) (point))
+ (or topspace-height (topspace--height))))
(defun topspace--height-to-make-buffer-centered ()
- "Return the necessary top space height to center selected window's
buffer."
- (let ((buffer-height (topspace--count-lines (window-start)
(window-end)))
- (result)
- (window-height (topspace--window-height)))
- (setq result (- (- (topspace--center-frame-line)
-
(round (/ buffer-height 2)))
-
(window-top-line (selected-window))))
- (when (> (+ result buffer-height) (- window-height
-
next-screen-context-lines))
- (setq result (- (- window-height buffer-height)
-
next-screen-context-lines)))
- result))
+ "Return the necessary top space height to center selected window's buffer."
+ (let ((buffer-height (topspace--count-lines (window-start) (window-end)))
+ (result)
+ (window-height (topspace--window-height)))
+ (setq result (- (- (topspace--center-frame-line)
+ (round (/ buffer-height 2)))
+ (window-top-line (selected-window))))
+ (when (> (+ result buffer-height) (- window-height
+ next-screen-context-lines))
+ (setq result (- (- window-height buffer-height)
+ next-screen-context-lines)))
+ result))
(defun topspace--center-frame-line ()
- "Return a center line number based on `topspace-center-position'.
+ "Return a center line number based on `topspace-center-position'.
The return value is only valid for windows starting at the top of the frame,
which must be accounted for in the calling functions."
- (round (* (frame-text-lines) topspace-center-position)))
+ (round (* (frame-text-lines) topspace-center-position)))
(defun topspace--recenter-buffers-p ()
- "Return non-nil if buffer is allowed to be auto-centered.
+ "Return non-nil if buffer is allowed to be auto-centered.
Buffers will not be auto-centered if `topspace-autocenter-buffers' is nil
or if the selected window is in a child-frame."
- (and topspace-autocenter-buffers
- (or ;; frame-parent is only provided in Emacs 26.1, so
first check
- ;; if fhat function is fboundp.
- (not (fboundp 'frame-parent))
- (not (frame-parent)))))
+ (and topspace-autocenter-buffers
+ (or ;; frame-parent is only provided in Emacs 26.1, so first check
+ ;; if fhat function is fboundp.
+ (not (fboundp 'frame-parent))
+ (not (frame-parent)))))
(defun topspace--window-height ()
- "Return the number of screen lines in the selected window rounded up."
- (ceiling (window-screen-lines)))
+ "Return the number of screen lines in the selected window rounded up."
+ (ceiling (window-screen-lines)))
(defun topspace--count-lines (start end)
- "Return screen lines between START and END.
+ "Return screen lines between START and END.
Like `count-screen-lines' except `count-screen-lines' will
return unexpected value when END is in column 0. This fixes that issue."
- (let ((adjustment 0) (column))
- (save-excursion
- (goto-char end)
- (setq column (mod (current-column) (window-text-width)))
- (unless (= column 0) (setq adjustment -1)))
- (+ (count-screen-lines start end) adjustment)))
+ (let ((adjustment 0) (column))
+ (save-excursion
+ (goto-char end)
+ (setq column (mod (current-column) (window-text-width)))
+ (unless (= column 0) (setq adjustment -1)))
+ (+ (count-screen-lines start end) adjustment)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Overlay drawing
(defun topspace--put (&optional height)
- "Put/draw top space as an overlay with the suggested line height
HEIGHT."
- (let ((old-height (topspace--height)))
- (when height (setq height (topspace--set-height height)))
- (when (not height) (setq height old-height))
- (when (and (> height 0) (> height old-height))
- (let ((lines-past-max (topspace--total-lines-past-max
height)))
- (when (> lines-past-max 0) (forward-line (*
lines-past-max -1)))))
- (let ((topspace (make-overlay 0 0)))
- (remove-overlays 1 1 'topspace--remove-from-window-tag
-
(selected-window))
- (overlay-put topspace 'window (selected-window))
- (overlay-put topspace 'topspace--remove-from-window-tag
-
(selected-window))
- (overlay-put topspace 'topspace--remove-from-buffer-tag
t)
- (overlay-put topspace 'before-string (when (> height 0)
-
(make-string height ?\n))))
- height))
+ "Put/draw top space as an overlay with the suggested line height HEIGHT."
+ (let ((old-height (topspace--height)))
+ (when height (setq height (topspace--set-height height)))
+ (when (not height) (setq height old-height))
+ (when (and (> height 0) (> height old-height))
+ (let ((lines-past-max (topspace--total-lines-past-max height)))
+ (when (> lines-past-max 0) (forward-line (* lines-past-max -1)))))
+ (let ((topspace (make-overlay 0 0)))
+ (remove-overlays 1 1 'topspace--remove-from-window-tag
+ (selected-window))
+ (overlay-put topspace 'window (selected-window))
+ (overlay-put topspace 'topspace--remove-from-window-tag
+ (selected-window))
+ (overlay-put topspace 'topspace--remove-from-buffer-tag t)
+ (overlay-put topspace 'before-string (when (> height 0)
+ (make-string height ?\n))))
+ height))
(defun topspace--put-increase-height (total-lines)
- "Increase the top space line height by the suggested amount of
TOTAL-LINES."
- (topspace--put (+ (topspace--height) total-lines)))
+ "Increase the top space line height by the suggested amount of TOTAL-LINES."
+ (topspace--put (+ (topspace--height) total-lines)))
(defun topspace--put-decrease-height (total-lines)
- "Decrease the top space line height by the suggested amount of
TOTAL-LINES."
- (topspace--put (- (topspace--height) total-lines)))
+ "Decrease the top space line height by the suggested amount of TOTAL-LINES."
+ (topspace--put (- (topspace--height) total-lines)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Hooks
(defun topspace--window-configuration-change ()
- "Update top spaces when window buffers change or windows are resized."
- (let ((current-height (topspace--window-height)) (window
(selected-window)))
- (let ((previous-height (alist-get window
topspace--previous-window-heights
-
current-height)))
- (if (and (topspace--recenter-buffers-p)
- (not (=
previous-height current-height)))
- (topspace-recenter-buffer)
- (topspace--put))
- (setf (alist-get window
topspace--previous-window-heights)
- current-height))))
+ "Update top spaces when window buffers change or windows are resized."
+ (let ((current-height (topspace--window-height)) (window (selected-window)))
+ (let ((previous-height (alist-get window topspace--previous-window-heights
+ current-height)))
+ (if (and (topspace--recenter-buffers-p)
+ (not (= previous-height current-height)))
+ (topspace-recenter-buffer)
+ (topspace--put))
+ (setf (alist-get window topspace--previous-window-heights)
+ current-height))))
(defun topspace--pre-command ()
- "Reduce the amount of code that must execute in
`topspace--post-command'."
- (setq-local topspace--pre-command-point (window-start))
- (setq-local topspace--pre-command-window-start (window-start)))
+ "Reduce the amount of code that must execute in `topspace--post-command'."
+ (setq-local topspace--pre-command-point (window-start))
+ (setq-local topspace--pre-command-window-start (window-start)))
(defun topspace--post-command ()
- "Gradually reduce top space before the cursor will move past the
bottom."
- (when (and (= topspace--pre-command-window-start 1)
- (< (- (line-number-at-pos
(point))
-
(line-number-at-pos topspace--pre-command-point))
-
(topspace--window-height)))
- (let ((topspace-height (topspace--height))
(total-lines-past-max))
- (when (> topspace-height 0)
- (setq total-lines-past-max
(topspace--total-lines-past-max
-
topspace-height))
- (when (> total-lines-past-max 0)
- (topspace--put-decrease-height
total-lines-past-max))))))
+ "Gradually reduce top space before the cursor will move past the bottom."
+ (when (and (eq (get-buffer-window (current-buffer)) (selected-window))
+ (= topspace--pre-command-window-start 1)
+ (< (- (line-number-at-pos (point))
+ (line-number-at-pos topspace--pre-command-point))
+ (topspace--window-height)))
+ (let ((topspace-height (topspace--height)) (total-lines-past-max))
+ (when (> topspace-height 0)
+ (setq total-lines-past-max (topspace--total-lines-past-max
+ topspace-height))
+ (when (> total-lines-past-max 0)
+ (topspace--put-decrease-height total-lines-past-max))))))
(defvar topspace--hook-alist
- '((window-configuration-change-hook .
topspace--window-configuration-change)
- (pre-command-hook . topspace--pre-command)
- (post-command-hook . topspace--post-command))
- "A list of hooks to add/remove in the format (hook-variable .
function).")
+ '((window-configuration-change-hook . topspace--window-configuration-change)
+ (pre-command-hook . topspace--pre-command)
+ (post-command-hook . topspace--post-command))
+ "A list of hooks to add/remove in the format (hook-variable . function).")
(defun topspace--add-hooks ()
- "Add hooks defined in `topspace--hook-alist'."
- (dolist (hook-func-pair topspace--hook-alist)
- (add-hook (car hook-func-pair) (cdr hook-func-pair) 0 t)))
+ "Add hooks defined in `topspace--hook-alist'."
+ (dolist (hook-func-pair topspace--hook-alist)
+ (add-hook (car hook-func-pair) (cdr hook-func-pair) 0 t)))
(defun topspace--remove-hooks ()
- "Remove hooks defined in `topspace--hook-alist'."
- (dolist (hook-func-pair topspace--hook-alist)
- (remove-hook (car hook-func-pair) (cdr hook-func-pair) t)))
+ "Remove hooks defined in `topspace--hook-alist'."
+ (dolist (hook-func-pair topspace--hook-alist)
+ (remove-hook (car hook-func-pair) (cdr hook-func-pair) t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; User functions
;;;###autoload
(defun topspace-recenter-buffer ()
- "Add enough top space in the selected window to center small buffers.
+ "Add enough top space in the selected window to center small buffers.
Top space will not be added if the number of text lines in the buffer is larger
than or close to the selected window's height.
@@ -342,60 +348,53 @@ than or close to the selected window's height.
Customize `topspace-center-position' to adjust the centering position.
Customize `topspace-autocenter-buffers' to run this command automatically
after first opening buffers and after window sizes change."
- (interactive)
- (let ((center-height (topspace--height-to-make-buffer-centered)))
- (setf (alist-get (selected-window) topspace--autocenter-heights)
- center-height)
- (topspace--put center-height)))
+ (interactive)
+ (let ((center-height (topspace--height-to-make-buffer-centered)))
+ (setf (alist-get (selected-window) topspace--autocenter-heights)
+ center-height)
+ (topspace--put center-height)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Mode definition and setup
(defun topspace--enable-p ()
- "Return non-nil if buffer is allowed to enable `topspace-mode.'.
+ "Return non-nil if buffer is allowed to enable `topspace-mode.'.
Topspace will not be enabled for:
- minibuffers
- ephemeral buffers (See Info node `(elisp)Buffer Names')
- if variable `topspace-mode' is already enabled"
- (not (or topspace--enabled
- (minibufferp) (string-prefix-p " "
(buffer-name)))))
+ (not (or topspace--enabled
+ (minibufferp) (string-prefix-p " " (buffer-name)))))
(defun topspace--enable ()
- "Enable variable `topspace-mode' if not already enabled, else do
nothing."
- (interactive)
- (when (topspace--enable-p)
- (topspace--add-hooks)
- (setq topspace--enabled t)
- (advice-add #'scroll-up :filter-args
#'topspace--filter-args-scroll-up)
- (advice-add #'scroll-down :filter-args
-
#'topspace--filter-args-scroll-down)
- (advice-add #'scroll-up :after #'topspace--after-scroll)
- (advice-add #'scroll-down :after #'topspace--after-scroll)
- (advice-add #'recenter :after #'topspace--after-recenter)))
+ "Enable variable `topspace-mode' if not already enabled, else do nothing."
+ (when (topspace--enable-p)
+ (topspace--add-hooks)
+ (setq topspace--enabled t)
+ (advice-add #'scroll-up :filter-args #'topspace--filter-args-scroll-up)
+ (advice-add #'scroll-down :filter-args
+ #'topspace--filter-args-scroll-down)
+ (advice-add #'scroll-up :after #'topspace--after-scroll)
+ (advice-add #'scroll-down :after #'topspace--after-scroll)
+ (advice-add #'recenter :after #'topspace--after-recenter)))
(defun topspace--disable ()
- "Disable variable `topspace-mode' if already enabled, else do nothing."
- (interactive)
- (when topspace--enabled
- (setq topspace--enabled nil)
- (remove-overlays 1 1 'topspace--remove-from-buffer-tag t)
- (advice-remove #'scroll-up #'topspace--filter-args-scroll-up)
- (advice-remove #'scroll-down
#'topspace--filter-args-scroll-down)
- (advice-remove #'scroll-up #'topspace--after-scroll)
- (advice-remove #'scroll-down #'topspace--after-scroll)
- (advice-remove #'recenter #'topspace--after-recenter)
- (topspace--remove-hooks)))
-
-(defvar topspace-keymap (make-sparse-keymap)
- "Keymap for Topspace commands.
-By default this is left empty for users to set with their own
-preferred bindings.")
+ "Disable variable `topspace-mode' if already enabled, else do nothing."
+ (when topspace--enabled
+ (setq topspace--enabled nil)
+ (remove-overlays 1 1 'topspace--remove-from-buffer-tag t)
+ (advice-remove #'scroll-up #'topspace--filter-args-scroll-up)
+ (advice-remove #'scroll-down #'topspace--filter-args-scroll-down)
+ (advice-remove #'scroll-up #'topspace--after-scroll)
+ (advice-remove #'scroll-down #'topspace--after-scroll)
+ (advice-remove #'recenter #'topspace--after-recenter)
+ (topspace--remove-hooks)))
;;;###autoload
(define-minor-mode topspace-mode
- "Scroll above the top line to vertically center top text.
+ "Scroll above the top line to vertically center top text.
Gives the effect of having blank space/padding/margin being automatically
drawn above the top text line using overlays as you scroll above,
@@ -412,16 +411,16 @@ ARG, enable variable `topspace-mode' if ARG is positive,
otherwise disable it.
When called from Lisp, enable variable `topspace-mode' if ARG is omitted,
nil or positive. If ARG is `toggle', toggle variable `topspace-mode'.
Otherwise behave as if called interactively."
- :init-value nil
- :ligher topspace-mode-line
- :keymap topspace-keymap
- :group 'topspace
- (if topspace-mode (topspace--enable) (topspace--disable)))
+ :init-value nil
+ :ligher topspace-mode-line
+ :keymap topspace-keymap
+ :group 'topspace
+ (if topspace-mode (topspace--enable) (topspace--disable)))
;;;###autoload
(define-globalized-minor-mode global-topspace-mode topspace-mode
- topspace-mode
- :group 'topspace)
+ topspace-mode
+ :group 'topspace)
(provide 'topspace)
- [elpa] externals/topspace a3e7d6ce73 174/181: Update description, (continued)
- [elpa] externals/topspace a3e7d6ce73 174/181: Update description, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 86efd067c8 175/181: Update description, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace fa67b67e1a 181/181: Update NEWS.md, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace b397dd8a18 177/181: Update description, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 23ad7729db 178/181: Update description, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 565b9a4e71 006/181: - added support for wrapped lines or visual-line-mode, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 770de4987f 009/181: Update README.md, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace f0dbb7b3ca 015/181: Make `M-x checkdoc` happy with docstrings, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 452e892635 017/181: Make topspace-enable and topspace-disable private functions, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace ece749cd58 018/181: Move topspace-keymap definition to remove warning, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 1049ef1b0e 019/181: Make topspace-enable and topspace-disable private functions,
ELPA Syncer <=
- [elpa] externals/topspace e5b65eccf9 010/181: Update and rename vertical-center-mode.el to topspace.el, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 960c5cae34 022/181: Reflect changes to customization variable docstrings, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace c8161ec68e 013/181: Update topspace.el, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 164e4aa1b9 026/181: Make auto-center-buffers update buffer in Emacs 26 when mode is first turned on, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 4a69b2eb74 027/181: Fix issue when calling recenter or recenter-top-bottom interactively, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 8a6225639b 030/181: Update to more clear GIF in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace f92cefa47c 032/181: Expand upon customization options in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 919774a212 033/181: Expand upon customization options in README, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 25841387a5 035/181: Raise topspace-center-position default to an objectively better position, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 532509d6ce 036/181: Make README prettier, ELPA Syncer, 2022/08/23