fix(visual-fill-column): improve line number detection
This commit is contained in:
parent
05fbbcb21f
commit
9394869bb3
1 changed files with 14 additions and 8 deletions
22
config.org
22
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.
|
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
|
#+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)
|
(require 'visual-fill-column)
|
||||||
(setq-local
|
(let ((dw (line-number-display-width)))
|
||||||
visual-fill-column-extra-text-width
|
;; 2 extra columns for padding (when line numbers are on)
|
||||||
(cons 0 (if display-line-numbers-mode
|
(when display-line-numbers
|
||||||
;; Width of line number + 2 padding columns
|
(setq dw (+ dw 2)))
|
||||||
(+ 2 (line-number-display-width))
|
(unless (= dw (or (cdr visual-fill-column-extra-text-width) 0))
|
||||||
0)))
|
(setq-local visual-fill-column-extra-text-width
|
||||||
(visual-fill-column--adjust-window))
|
(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
|
#+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
|
** Dashboard
|
||||||
|
|
||||||
#+call: confpkg("Dashboard")
|
#+call: confpkg("Dashboard")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue