Closed countvajhula closed 2 years ago
Since I haven't used line numbering like this, I'm reading up to get familiar. What I've learned:
In older Emacs there is linum-mode
(and global-linum-mode
) implemented in Emacs Lisp.
In Emacs 29 built from source, I see display-line-numbers-mode
(and global-display-line-numbers-mode
), which are just a minor mode wrapper around a display-line-numbers
variable, the implementation of which is in C.
With
global-line-numbers-mode
enabled,
Do you actually mean global-display-line-numbers-mode
? I'm not trying to be picky. I want to make sure there's not some third line numbering mode out there.
Never mind -- in your work-around you mention display-line-number-mode
, so it was just a typo earlier, and you definitely do mean the new/improved mode.
From my limited research, so far, I don't see that the display-line-numbers
mechanism reveals the necessary width information, such that racket-describe-mode
could tell shr
(which does the HTML layout) that the effective window-width
is smaller.
Instead, racket-describe-mode
could disable display-line-numbers-mode
-- to do the work-around you describe, but do it automatically for you. Something like (using code that will work in older Emacs):
(when (and (boundp 'display-line-numbers-mode)
display-line-numbers-mode
(fboundp 'display-line-numbers-mode))
(display-line-numbers-mode -1))
Anyway that's my least-worst idea, for now.
Just confirming, apologies for the typo! I did mean global-display-line-numbers-mode
😄
No worries. :smile: If I'd already known more about the line number modes in Emacs, my brain probably would have auto-corrected the typo and not even noticed it.
Interestingly, display-line-numbers-mode
, the variable, is defined even back in Emacs 25.2, but it has no effect. And for example transient
(the menu system for magit
) does (setq display-line-number-mode)
; this disables line-numbers in newer Emacs, and is a no-op in older ones.
I think I'll stick with the idea of disabling the minor mode -- and extend that idea to include linum-mode
, too. Say with a little DRY macro:
(cl-macrolet ((disable (id) `(and (boundp ',id) ,id (fboundp ',id) (,id -1))))
(disable linum-mode)
(disable display-line-numbers-mode))
With
global-line-numbers-mode
enabled, describe buffers open with line numbers in the leftmost column. This causes the documentation to spill text over on each line, probably because it is estimating the line width without taking the line numbers column into account.Before, with line numbers:
A workaround is to disable line numbers in
racket-describe-mode
buffers:After, without line numbers:
Possible solutions, either: (a) disable line numbers upon entry to racket-describe-mode, or (b) take the line numbers column width into account. Of these, (b) would probably be the more robust solution, as it could be general and handle "all" cases where there may be things taking up column-width on the screen that aren't reflected in just the buffer contents.