I am attempting to set up the new emacs 26.1 display-line-numbers-mode
as described in this comment: hybrid line number mode in emacs?
I have added this to my .emacs file:
(setq display-line-numbers 'relative
display-line-numbers-current-absolute t)
When I evaluate the above expression the desired behavior is produced, but it is not persistent. For example, it is not automatically evaluated on restarting emacs, and when I try to use my keybinding toggle:
(global-set-key (kbd "C-c l") 'display-line-numbers-mode)
The line numbers that are toggled are not relative.
What is the appropriate way to set display-line-numbers
to relative
in my configuration file so that using the keybinding results in relative line numbers?
setq-default
withdisplay-line-numbers 'relative
in my .emacs file but it does not seem to work. – Marcel Jun 01 '18 at 01:41(setq-default display-line-numbers 'realtive)
and then typeM-x describe-variable RET display-line-numbers RET
, the*Help*
buffer says: "... Its value is ‘realtive’. Original value was nil." If you place that same code in your.emacs
orinit.el
file, it should show the same thing if you restart Emacs and typeM-x describe-variable ...
Is that what it says? – lawlist Jun 01 '18 at 01:47C-c l
as set above reverts it to absolute line numbering. – Marcel Jun 01 '18 at 01:51C-c l
is undefined in a new installation of Emacs 26.1 (with no user-configuration) infundamental-mode
. What function is yourC-c l
bound to? Type:C-h k
orM-x describe-key
. – lawlist Jun 01 '18 at 01:56(global-set-key (kbd "C-c l") 'display-line-numbers-mode)
– Marcel Jun 01 '18 at 01:59M-x find-function RET display-line-numbers-mode RET
, we see that the variabledisplay-line-numbers
is set to the value ofdisplay-line-numbers-type
. And, we already know now thatdisplay-line-numbers
is a buffer-local variable andsetq
sets that variable locally in the buffer that has been selected. If we typeM-x describe-variable RET display-line-numbers-type RET
, we see that it is a global variable whose value ist
. FYI: I had to evaluate(require 'display-line-numbers)
to load the entire library to look-up the aforementioned variable. Set it to'relative
. – lawlist Jun 01 '18 at 02:05