From f427c8a30ed6d90c30c816f2b55c4933690325d1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 Sep 2023 23:52:27 +0200 Subject: [PATCH] tweak: scroll-conservatively = 10 Forces the window to recenter if the cursor moves >=10 lines off-screen. This makes some of our manual recentering elsewhere unnecessary. --- lisp/doom-editor.el | 4 ---- lisp/doom-ui.el | 6 ++++-- modules/completion/ivy/config.el | 1 - modules/lang/cc/config.el | 3 +-- modules/lang/emacs-lisp/config.el | 3 --- modules/tools/magit/config.el | 4 ---- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lisp/doom-editor.el b/lisp/doom-editor.el index aa572e32d..aa90e4f72 100644 --- a/lisp/doom-editor.el +++ b/lisp/doom-editor.el @@ -586,10 +586,6 @@ current buffer." (with-current-buffer buf (goto-char pos))))))))) -;;;###package imenu -(add-hook 'imenu-after-jump-hook #'recenter) - - (use-package! smartparens ;; Auto-close delimiters and blocks as you type. It's more powerful than that, ;; but that is all Doom uses it for. diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index 05cc20c12..8f4a4e371 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -156,8 +156,10 @@ or if the current buffer is read-only or not file-visiting." ;; cursor more than N lines past window edges (where N is the settings of ;; `scroll-conservatively'). This is especially slow in larger files ;; during large-scale scrolling commands. If kept over 100, the window is - ;; never automatically recentered. - scroll-conservatively 101 + ;; never automatically recentered. The default (0) triggers this too + ;; aggressively, so I've set it to 10 to recenter if scrolling too far + ;; off-screen. + scroll-conservatively 10 scroll-margin 0 scroll-preserve-screen-position t ;; Reduce cursor lag by a tiny bit by not auto-adjusting `window-vscroll' diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index c9af7ee58..23568f9b3 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -237,7 +237,6 @@ results buffer.") ;; Record in jumplist when opening files via counsel-{ag,rg,pt,git-grep} (add-hook 'counsel-grep-post-action-hook #'better-jumper-set-jump) - (add-hook 'counsel-grep-post-action-hook #'recenter) (ivy-add-actions 'counsel-rg ; also applies to `counsel-rg' '(("O" +ivy-git-grep-other-window-action "open in other window"))) diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index c0fb46811..221d7b165 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -229,8 +229,7 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e ;; than display a jarring confirmation prompt for killing it. (add-hook! 'kill-emacs-hook (ignore-errors (rtags-cancel-process))) - (add-hook 'rtags-jump-hook #'better-jumper-set-jump) - (add-hook 'rtags-after-find-file-hook #'recenter)) + (add-hook 'rtags-jump-hook #'better-jumper-set-jump)) ;; diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index d6393e384..b089ff53c 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -112,9 +112,6 @@ See `+emacs-lisp-non-package-mode' for details.") (when +emacs-lisp-enable-extra-fontification `((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face))))) - ;; Recenter window after following definition - (advice-add #'elisp-def :after #'doom-recenter-a) - (defadvice! +emacs-lisp-append-value-to-eldoc-a (fn sym) "Display variable value next to documentation in eldoc." :around #'elisp-get-var-docstring diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 5878ae688..988cd2143 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -50,10 +50,6 @@ Only has an effect in GUI Emacs.") ;; ...then refresh the rest only when we switch to them, not all at once. (add-hook 'doom-switch-buffer-hook #'+magit-revert-buffer-maybe-h) - ;; Center the target file, because it's poor UX to have it at the bottom of - ;; the window after invoking `magit-status-here'. - (advice-add #'magit-status-here :after #'doom-recenter-a) - ;; The default location for git-credential-cache is in ;; ~/.cache/git/credential. However, if ~/.git-credential-cache/ exists, then ;; it is used instead. Magit seems to be hardcoded to use the latter, so here