I wrote a function to enable some minor modes when another minor mode is enabled:
(defun prose-mode()
(display-line-numbers-mode)
(variable-pitch-mode))
I added prose-mode
as a hook for olivetti-mode
:
(add-hook 'olivetti-mode-hook 'prose-mode)
The hook is working fine and prose-mode
gets ivoked on M-x olivetti-mode
.
However, when I do that again to disable the mode, the line numbers don't reappear. variable-pitch-mode
is toggling and I get my monospaced font back.
In general, is this the right way to do what I'm trying to do?
Inside prose-mode
, should I check for the current minor mode using a conditional statement to enable/disable the other modes?
olivetti-mode
won't run the hook, if you mean that the line numbers doesn't toggle when you run againprose-mode
you should use(display-line-numbers-mode 'toggle)
instead. – Muihlinn May 6 '20 at 12:19prose-mode
is misleading, as it's is not a minor mode, minor mode is usually defined viadefine-minor-mode
, a better name issixter-olivetti-mode-setup
(?) and you can detect if the olivetti mode is on or off via the variableolivetti-mode
. – xuchunyang May 6 '20 at 12:37