When I narrow an org mode header into a subtree(using command org-narrow-to-subtree) in vanilla Emacs, the line number counts from 1 in the subtree, but when I create a subtree in Doom Emacs, the line number counts from the original line number(e.g. if the header is on the 8000th line in the original file, the header in the subtree still starts from 8000, instead of 1). How can I make it count from 1 in the subtree?
1 Answer
Put this in an appropriate place in your emacs configuration (not sure what file that is for doom):
(custom-set-variables
'(display-line-numbers-widen nil))
I think you could use setq-default
instead if you like, but I hear there are some subtleties that make custom-set-variables
a better choice for customize-able variables -- it's OK to use custom-set-variables
in your ordinary emacs config however you like -- just don't edit by hand the special customize call that is commented with ;; custom-set-variables was added by Custom.
unless you know what you're doing.
Alternatively, you can use M-x customize-variable <RET> display-line-numbers-widen <RET>
.
-
Thanks, it worked! And as you said, only
customize-variable
worked.setq
didn't work. Maybecustomize-variable
has higher priority.– SeareneMar 11, 2021 at 12:48 -
1Ah it automatically becomes buffer-local when set, so probably you'd have to use
setq-default
if you want to set a global default value across buffers (though since this is C-implemented, maybe it's even more special than that? Haven't tested). Corrected my answer Mar 12, 2021 at 13:12
display-line-numbers-mode
because I've checked the value ofdisplay-line-numbers-mode
, which ist
. I also tried disabling the mode by running thedisplay-line-numbers-mode
command, the line numbers disappeared. Rerun the command redisplayed line numbers. So I think I'm using this mode to show line numbers.display-line-numbers
say "If the value is t, display the absolute number of each line of a buffer shown in a window. Absolute line numbers count from the beginning of the current narrowing, or from buffer beginning.". You might also poke around in variables starting withdisplay-line
(something like ivy or helm together withC-h v
is helpful for that, orM-x customize-group <RET> display-line-numbers
<RET>)