Update, simplify and add smooth scrolling toggle on `SPC t v`

This commit is contained in:
syl20bnr 2016-03-02 09:13:09 -05:00
parent b7f4d90ce2
commit 0ca738989e
2 changed files with 26 additions and 22 deletions

View File

@ -919,6 +919,7 @@ and ~T~):
| ~SPC t l~ | toggle truncate lines |
| ~SPC t L~ | toggle visual lines |
| ~SPC t n~ | toggle line numbers |
| ~SPC t v~ | toggle smooth scrolling |
| Key Binding | Description |
|-------------+--------------------------------------------------------------|
@ -1405,9 +1406,11 @@ On Windows, you may want to disable it. To disable the smooth scrolling set the
=dotspacemacs-smooth-scrolling= variable in your =~/.spacemacs= to =nil=:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-smooth-scrolling t)
(setq-default dotspacemacs-smooth-scrolling nil)
#+END_SRC
You can also toggle smooth scrolling with ~SPC t v~.
*** Vim motions with avy
Spacemacs uses the =evil= integration of [[https://github.com/abo-abo/avy][avy]] which enables the
invocation of =avy= during motions.

View File

@ -233,32 +233,33 @@
(spacemacs//neotree-key-bindings)))
(defun spacemacs-ui-visual/init-smooth-scrolling ()
(defun spacemacs//unset-scroll-margin ()
"Set scroll-margin to zero."
(setq-local scroll-margin 0))
(use-package smooth-scrolling
:if dotspacemacs-smooth-scrolling
:init (setq smooth-scroll-margin 5
scroll-conservatively 101
scroll-preserve-screen-position t
auto-window-vscroll nil)
:config
:init
(progn
(setq scroll-margin 5)
(setq smooth-scroll-margin 5)
(spacemacs|add-toggle smooth-scrolling
:status smooth-scrolling-mode
:on (progn
(smooth-scrolling-mode)
(enable-smooth-scroll-for-function previous-line)
(enable-smooth-scroll-for-function next-line)
(enable-smooth-scroll-for-function isearch-repeat))
:off (progn
(smooth-scrolling-mode -1)
(disable-smooth-scroll-for-function previous-line)
(disable-smooth-scroll-for-function next-line)
(disable-smooth-scroll-for-function isearch-repeat))
:documentation "Smooth scrolling."
:evil-leader "tv")
(unless dotspacemacs-smooth-scrolling
(spacemacs/toggle-smooth-scrolling-off))
;; add hooks here only for emacs built-in packages that are not owned
;; by a layer.
(defun spacemacs//unset-scroll-margin ()
"Set scroll-margin to zero."
(setq-local scroll-margin 0))
(spacemacs/add-to-hooks 'spacemacs//unset-scroll-margin
'(messages-buffer-mode-hook))))
(unless dotspacemacs-smooth-scrolling
;; deactivate smooth-scrolling advices
(ad-disable-advice 'previous-line 'after 'smooth-scroll-down)
(ad-activate 'previous-line)
(ad-disable-advice 'next-line 'after 'smooth-scroll-up)
(ad-activate 'next-line)
(ad-disable-advice 'isearch-repeat 'after 'isearch-smooth-scroll)
(ad-activate 'isearch-repeat)))
'(messages-buffer-mode-hook)))))
(defun spacemacs-ui-visual/init-spaceline ()
(use-package spaceline-config