Closed chmol closed 4 years ago
Disabling a minor mode in Elisp is done by passing e.g., -1
to the function. If you pass nil
, the mode is actually enabled, not disabled.
That's counter-intuitive, but the reason is that it allows for activating a minor mode just by adding its function name to a mode hook.
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
This calls the function display-line-numbers-mode
without any argument, but internally there is no distinction between calling a function with no arguments and calling it with the argument nil
.
So basically, your first invocation is actually the same as the line above...
If you do:
(add-hook 'writeroom-mode-hook (lambda () (display-line-numbers-mode -1)))
it should work.
Why setting the variable display-line-numbers
directly doesn't work, I don't know.
Thank you so much for taking the time to explain the logic behind it. Its working and my writing environment is perfect !
Glad it's working!
Hello,
I'm enjoying this packages but I have the following issues: line number are displayed when the mode is started which is expected as I have the following in my init.el
But I fail hiding them when I add a specific hook
(add-hook 'writeroom-mode-hook (lambda () (display-line-numbers-mode nil) ))
or
(add-hook 'writeroom-mode-hook (lambda () (setq-local display-line-numbers nil)))
Am I missing something?
Thanks,