diff --git a/config.org b/config.org index 03d3b83..74370fb 100644 --- a/config.org +++ b/config.org @@ -1304,17 +1304,23 @@ The =visual-fill-column= package works by expanding the window's right margin. T When a buffer has line numbers, they can interfere with the margins and make the line smaller than it should be. We can mitigate this issue by adding extra columns to the window. #+begin_src emacs-lisp -(add-hook! display-line-numbers-mode +(defun ~/update-visual-fill-column-line-numbers (&optional _s _e _len) (require 'visual-fill-column) - (setq-local - visual-fill-column-extra-text-width - (cons 0 (if display-line-numbers-mode - ;; Width of line number + 2 padding columns - (+ 2 (line-number-display-width)) - 0))) - (visual-fill-column--adjust-window)) + (let ((dw (line-number-display-width))) + ;; 2 extra columns for padding (when line numbers are on) + (when display-line-numbers + (setq dw (+ dw 2))) + (unless (= dw (or (cdr visual-fill-column-extra-text-width) 0)) + (setq-local visual-fill-column-extra-text-width + (cons 0 dw)) + (visual-fill-column--adjust-window)))) + +(add-hook! '(display-line-numbers-mode-hook post-command-hook doom-switch-buffer-hook) + #'~/update-visual-fill-column-line-numbers) #+end_src +We unfortunately have to make this check /very/ often, anywhere that could conceivably change the output of ~line-number-display-width~. This includes all buffer movement commands, which unfortunately don't have a hook + ** Dashboard #+call: confpkg("Dashboard")