mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
feat(smooth-scroll): add +interpolate flag
Adds optional scroll interpolation/animation in #8335 via the good-scroll package. Command support is light right now, but I plan to expand on it later, and I welcome PRs to do so in the meantime. Ref: #8335
This commit is contained in:
@ -4,18 +4,21 @@
|
|||||||
#+since: 25.05.0
|
#+since: 25.05.0
|
||||||
|
|
||||||
* Description :unfold:
|
* Description :unfold:
|
||||||
This module activates OS-independent smooth scrolling in Emacs. This primarily
|
This module enables multiple kinds of smooth scrolling in Emacs. Its primary
|
||||||
benefits trackpad and scroll wheel users (not so much those that scroll via
|
function is to make input scrolling (on trackpads and scroll wheels)
|
||||||
their keyboards), by utilizing the [[https://github.com/jdtsmith/ultra-scroll][ultra-scroll]] package.
|
pixel-smooth. With the =+interpolate= flag, it performs interpolated scrolling on
|
||||||
|
a growing list of scroll commands that traverse larger distances, smoothly
|
||||||
|
scrolling from point A to B on PgUp or PgDown (or [[kbd:][C-d]]/[[kbd:][C-u]] for Evil users).
|
||||||
|
|
||||||
#+begin_quote
|
#+begin_quote
|
||||||
This module requires Emacs 29.1 or newer.
|
This module requires Emacs 29.1 or newer.
|
||||||
#+end_quote
|
#+end_quote
|
||||||
|
|
||||||
#+begin_quote
|
#+begin_quote
|
||||||
For optimal performance from this module, it's highly recommended you use
|
Scroll interpolation support is currently limited to the ~scroll-up~ and
|
||||||
Emacs with native-compilation. MacOS users may also have a better experience
|
~scroll-down~ commands, and any command that calls them (like ~evil-scroll-down~
|
||||||
using the [[https://bitbucket.org/mituharu/emacs-mac][emacs-mac]] fork of Emacs, available via Homebrew.
|
and ~evil-scroll-up~), so you're likely to find many scroll commands are not
|
||||||
|
interpolated. We welcome PRs to expand its support.
|
||||||
#+end_quote
|
#+end_quote
|
||||||
|
|
||||||
** Maintainers
|
** Maintainers
|
||||||
@ -24,10 +27,14 @@ their keyboards), by utilizing the [[https://github.com/jdtsmith/ultra-scroll][u
|
|||||||
[[doom-contrib-maintainer:][Become a maintainer?]]
|
[[doom-contrib-maintainer:][Become a maintainer?]]
|
||||||
|
|
||||||
** Module flags
|
** Module flags
|
||||||
/This module has no flags./
|
- +interpolate ::
|
||||||
|
Enables scroll interpolation for some larger-step scrolling commands. E.g.
|
||||||
|
PgUp and PgDown (or C-d/C-u for Evil users) will now smoothly scroll to its
|
||||||
|
destination rather than jump to it.
|
||||||
|
|
||||||
** Packages
|
** Packages
|
||||||
- [[doom-package:ultra-scroll]]
|
- [[doom-package:ultra-scroll]]
|
||||||
|
- [[doom-package:good-scroll]] if [[doom-module:+interpolate]]
|
||||||
|
|
||||||
** Hacks
|
** Hacks
|
||||||
/No hacks documented for this module./
|
/No hacks documented for this module./
|
||||||
@ -41,6 +48,12 @@ their keyboards), by utilizing the [[https://github.com/jdtsmith/ultra-scroll][u
|
|||||||
|
|
||||||
/This module has no external requirements./
|
/This module has no external requirements./
|
||||||
|
|
||||||
|
#+begin_quote
|
||||||
|
For optimal performance from this module, it's highly recommended you use
|
||||||
|
Emacs with native-compilation. MacOS users may also have a better experience
|
||||||
|
using the [[https://bitbucket.org/mituharu/emacs-mac][emacs-mac]] fork of Emacs, available via Homebrew.
|
||||||
|
#+end_quote
|
||||||
|
|
||||||
* Usage
|
* Usage
|
||||||
This module only needs to be activated to experience its benefits.
|
This module only needs to be activated to experience its benefits.
|
||||||
|
|
||||||
|
@ -11,3 +11,23 @@
|
|||||||
(add-hook 'ultra-scroll-hide-functions #'hl-todo-mode)
|
(add-hook 'ultra-scroll-hide-functions #'hl-todo-mode)
|
||||||
(add-hook 'ultra-scroll-hide-functions #'diff-hl-flydiff-mode)
|
(add-hook 'ultra-scroll-hide-functions #'diff-hl-flydiff-mode)
|
||||||
(add-hook 'ultra-scroll-hide-functions #'jit-lock-mode))
|
(add-hook 'ultra-scroll-hide-functions #'jit-lock-mode))
|
||||||
|
|
||||||
|
|
||||||
|
(use-package good-scroll
|
||||||
|
:when (modulep! +interpolate)
|
||||||
|
:hook (doom-first-input . good-scroll-mode)
|
||||||
|
:config
|
||||||
|
(defun good-scroll--convert-line-to-step (line)
|
||||||
|
(cond ((integerp line) (* line (line-pixel-height)))
|
||||||
|
((or (null line) (memq '- line))
|
||||||
|
(- (good-scroll--window-usable-height)
|
||||||
|
(* next-screen-context-lines (line-pixel-height))))
|
||||||
|
((line-pixel-height))))
|
||||||
|
|
||||||
|
(defadvice! good-scroll--scroll-up (&optional arg)
|
||||||
|
:override #'scroll-up
|
||||||
|
(good-scroll-move (good-scroll--convert-line-to-step arg)))
|
||||||
|
|
||||||
|
(defadvice! good-scroll--scroll-down (&optional arg)
|
||||||
|
:override #'scroll-down
|
||||||
|
(good-scroll-move (- (good-scroll--convert-line-to-step arg)))))
|
||||||
|
@ -4,3 +4,6 @@
|
|||||||
(package! ultra-scroll
|
(package! ultra-scroll
|
||||||
:recipe (:host github :repo "jdtsmith/ultra-scroll")
|
:recipe (:host github :repo "jdtsmith/ultra-scroll")
|
||||||
:pin "b72c507f6702db18d971a6b6bdc692e260f21159")
|
:pin "b72c507f6702db18d971a6b6bdc692e260f21159")
|
||||||
|
|
||||||
|
(when (modulep! +interpolate)
|
||||||
|
(package! good-scroll :pin "a7ffd5c0e5935cebd545a0570f64949077f71ee3"))
|
||||||
|
Reference in New Issue
Block a user