Skip to content

Commit

Permalink
Update, simplify and add smooth scrolling toggle on SPC t v
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Mar 2, 2016
1 parent b7f4d90 commit 0ca7389
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
5 changes: 4 additions & 1 deletion doc/DOCUMENTATION.org
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|-------------+--------------------------------------------------------------|
Expand Down Expand Up @@ -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.
Expand Down
43 changes: 22 additions & 21 deletions layers/+spacemacs/spacemacs-ui-visual/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0ca7389

Please sign in to comment.