[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/topspace 164e4aa1b9 026/181: Make auto-center-buffers u
From: |
ELPA Syncer |
Subject: |
[elpa] externals/topspace 164e4aa1b9 026/181: Make auto-center-buffers update buffer in Emacs 26 when mode is first turned on |
Date: |
Tue, 23 Aug 2022 12:58:30 -0400 (EDT) |
branch: externals/topspace
commit 164e4aa1b9f93ec4ca502520872918f2ea5e53cd
Author: Trevor Pogue <poguete@mcmaster.ca>
Commit: Trevor Pogue <poguete@mcmaster.ca>
Make auto-center-buffers update buffer in Emacs 26 when mode is first
turned on
---
topspace.el | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/topspace.el b/topspace.el
index 37c62dfc31..c6dce2e598 100644
--- a/topspace.el
+++ b/topspace.el
@@ -1,4 +1,4 @@
-;;; topspace.el --- Scroll above the top line to vertically center top text
-*- lexical-binding: t -*-
+;;; topspace.el --- Scroll above the top line to vertically center top text
with a scrollable top margin/padding -*- lexical-binding: t -*-
;; Copyright (C) 2021-2022 Trevor Edwin Pogue
@@ -23,9 +23,10 @@
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
-;; 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,
+;; Scroll above the top line to vertically center top text
+;; with a scrollable top margin/padding.
+;; An overlay is automatically drawn above the top text line
+;; as you scroll above,
;; giving the equivalent effect of being able to scroll above the top line.
;; No new keybindings are required as topspace automatically works for any
@@ -84,7 +85,6 @@ space should be reduced in size or not")
(defcustom topspace-autocenter-buffers
t
"Vertically center small buffers when first opened or window sizes change.
-
This is done by automatically calling `topspace-recenter-buffer',
which adds enough top space to center small buffers.
Top space will not be added if the number of text lines in the buffer is larger
@@ -97,7 +97,6 @@ Customize `topspace-center-position' to adjust the centering
position."
0.5
"Target 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
@@ -105,12 +104,10 @@ if `topspace-autocenter-buffers' is non-nil."
(defcustom topspace-mode-line " T"
"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
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)
@@ -155,7 +152,6 @@ TOTAL-LINES is used in the same way as in `scroll-up'."
(defun topspace--after-scroll (&optional total-lines)
"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)
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
@@ -210,7 +206,6 @@ If no previous value exists, return the appropriate value to
(defun topspace--correct-height (height)
"Return HEIGHT if a valid top space line height, else a valid value.
-
Valid top space line heights are:
- never negative,
- only positive when `window-start' equals 1,
@@ -257,7 +252,6 @@ which must be accounted for in the calling functions."
(defun topspace--recenter-buffers-p ()
"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
@@ -366,10 +360,8 @@ return unexpected value when END is in column 0. This
fixes that issue."
;;;###autoload
(defun topspace-recenter-buffer ()
"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.
-
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."
@@ -384,9 +376,7 @@ after first opening buffers and after window sizes change."
(defun topspace--enable-p ()
"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"
@@ -403,7 +393,9 @@ Topspace will not be enabled for:
#'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)))
+ (advice-add #'recenter :after #'topspace--after-recenter)
+ (dolist (window (get-buffer-window-list))
+ (with-selected-window window (topspace--put)))))
(defun topspace--disable ()
"Disable variable `topspace-mode' if already enabled, else do nothing."
@@ -420,19 +412,15 @@ Topspace will not be enabled for:
;;;###autoload
(define-minor-mode topspace-mode
"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,
-giving the equivalent effect of being able to scroll above the top line.
-
+It is like having a scrollable top margin/padding.
+An overlay is automatically drawn above the top text line as you scroll above,
+giving the effect of being able to scroll above the top line.
No new keybindings are required as topspace automatically works for any
commands or subsequent function calls which use `scroll-up', `scroll-down',
or `recenter' as the underlying primitives for scrolling. This includes all
scrolling commands/functions available in Emacs as far as the author is aware.
-
When called interactively, toggle variable `topspace-mode'. With prefix
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."
- [elpa] externals/topspace 23ad7729db 178/181: Update description, (continued)
- [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, 2022/08/23
- [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 <=
- [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
- [elpa] externals/topspace 24f0d8b35a 037/181: Update README header, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 94fe4ccf4c 038/181: Update README header, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace 820107a73a 039/181: Update README header, ELPA Syncer, 2022/08/23
- [elpa] externals/topspace a03735ae80 040/181: Add supporters section and emojis to README, ELPA Syncer, 2022/08/23