diff --git a/config.org b/config.org index e159e61..a8bffe5 100644 --- a/config.org +++ b/config.org @@ -2113,15 +2113,15 @@ The =indent-bars= package works by overriding the face used for displaying the w *** Evil Shift Width -The Vim/Evil keybinds =<= and =>= shift the target left or right by one indent respectively, where the specific offset it uses is determined by ~evil-shift-width~. Doom Emacs sets this equal to ~tab-width~, the displayed width of a hard tab, which is a little odd, as that doesn't actually have anything to do with the indentation settings of the current mode. We can fix this in a few different ways, but the simplest is to set ~tab-width~ to the offset to make everything consistent. +The Vim/Evil keybinds =<= and =>= shift the target left or right by one indent respectively, where the specific offset it uses is determined by ~evil-shift-width~. Doom Emacs sets this equal to ~tab-width~, the displayed width of a hard tab, which is a little odd, as that doesn't actually have anything to do with the indentation settings of the current mode. We can fix this by overriding the hook to set the shift width to our guessed offset, falling back on the default behavior otherwise. #+begin_src emacs-lisp -(add-hook! 'change-major-mode-after-body-hook - (defun ~/adjust-tab-width () - (unless (or (derived-mode-p 'org-mode) ;; Org mode is an exception - (local-variable-p 'tab-width)) - (setq-local tab-width (or (~/guess-offset-from-editorconfig) - tab-width))))) +(defadvice! ~/evil-adjust-shift-width-h () + :override #'+evil-adjust-shift-width-h + (setq-local evil-shift-width + (if (derived-mode-p 'org-mode) 2 + (or (~/guess-offset-from-editorconfig) + tab-width)))) #+end_src ** Marginalia