Commit 12fb8fa4669d

Vincent Demeester <vincent@sbr.pm>
2020-08-18 18:42:58
tools/emacs: add scroll configuration…
… and center minor mode. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 14bd705
Changed files (1)
tools
tools/emacs/config/config-navigating.el
@@ -3,6 +3,31 @@
 ;;; Navigation related configuration
 ;;; Code:
 
+(use-package emacs
+  :config
+  (setq-default scroll-preserve-screen-position t)
+  (setq-default scroll-conservatively 1) ; affects `scroll-step'
+  (setq-default scroll-margin 0)
+
+  (define-minor-mode vde/scroll-centre-cursor-mode
+    "Toggle centred cursor scrolling behaviour."
+    :init-value nil
+    :lighter " S="
+    :global nil
+    (if vde/scroll-centre-cursor-mode
+        (setq-local scroll-margin (* (frame-height) 2)
+                    scroll-conservatively 0
+                    maximum-scroll-margin 0.5)
+      (dolist (local '(scroll-preserve-screen-position
+                       scroll-conservatively
+                       maximum-scroll-margin
+                       scroll-margin))
+        (kill-local-variable `,local))))
+
+  ;; C-c l is used for `org-store-link'.  The mnemonic for this is to
+  ;; focus the Line and also works as a variant of C-l.
+  :bind ("C-c L" . vde/scroll-centre-cursor-mode))
+
 (use-package avy
   :disabled
   :bind (("C-c j"   . avy-goto-word-1)