From e06929ddafcca13392046e7c74e559d1cb5593dd Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Fri, 20 May 2016 23:34:32 -0400 Subject: [PATCH] Replace smooth-scrolling package by a native alternative My tests show that scroll-conservatively does the job, need your feedback on this. See https://github.com/syl20bnr/spacemacs/issues/6097 --- .../+spacemacs/spacemacs-ui-visual/funcs.el | 13 +++++++ .../spacemacs-ui-visual/packages.el | 38 +++++-------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/layers/+spacemacs/spacemacs-ui-visual/funcs.el b/layers/+spacemacs/spacemacs-ui-visual/funcs.el index 6794996da..4edc96a3b 100644 --- a/layers/+spacemacs/spacemacs-ui-visual/funcs.el +++ b/layers/+spacemacs/spacemacs-ui-visual/funcs.el @@ -9,6 +9,19 @@ ;; ;;; License: GPLv3 + +;; smooth scrolling + +(defun spacemacs/enable-smooth-scrolling () + "Enable smooth scrolling." + (interactive) + (setq scroll-conservatively 101)) + +(defun spacemacs/disable-smooth-scrolling () + "Enable smooth scrolling." + (interactive) + (setq scroll-conservatively 0)) + ;; neotree diff --git a/layers/+spacemacs/spacemacs-ui-visual/packages.el b/layers/+spacemacs/spacemacs-ui-visual/packages.el index 4659af782..c43204b23 100644 --- a/layers/+spacemacs/spacemacs-ui-visual/packages.el +++ b/layers/+spacemacs/spacemacs-ui-visual/packages.el @@ -18,7 +18,7 @@ neotree popup popwin - smooth-scrolling + (smooth-scrolling :location built-in) spaceline (zoom-frm :location local))) @@ -247,33 +247,15 @@ popwin:special-display-config)))))) (defun spacemacs-ui-visual/init-smooth-scrolling () - (use-package smooth-scrolling - :init - (progn - (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") - (when dotspacemacs-smooth-scrolling - (spacemacs/toggle-smooth-scrolling-on)) - ;; 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))))) + (setq scroll-preserve-screen-position t + scroll-margin 0 + scroll-conservatively (if dotspacemacs-smooth-scrolling 101 0)) + (spacemacs|add-toggle smooth-scrolling + :status (= 101 scroll-conservatively) + :on (spacemacs/enable-smooth-scrolling) + :off (spacemacs/disable-smooth-scrolling) + :documentation "Smooth scrolling." + :evil-leader "tv")) (defun spacemacs-ui-visual/init-spaceline () (use-package spaceline-config