super_momonga · 2022-06-28 02:55
*Normie Question*
How can i do that the minor mode of _Olivetti_, it gets enable by default in all buffers that i open?, i also wish to know how to do this, as in that way i could be able to it with other modes that i have planned
ntwmbc · 2022-06-28 10:00
This is usually done with hooks. I don't have olivetti mode installed, but to enable it for all programming modes you could do
(add-hook 'prog-mode-hook #'olivetti-mode)
Depending on your use case that might be all relevant modes or not. You could put them all in a list and add it to all of them, something like this
(dolist (f '(prog-mode-hook org-mode-hook text-mode-hook))
(add-hook f #'olivetti-mode))
I don't know if opening org-mode buffers trigger the text-mode-hook, so I added it for safety.
I'm hardly an expert at elisp, and there might be better ways to do it. This is similar to what I do in my own config though, and it seems to work.
super_momonga · 2022-06-28 12:07
thanks man, i still dont understand the differences beetween hooks, variables and functions
ntwmbc · 2022-06-28 12:46
The manual is your friend! https://www.gnu.org/software/emacs/manual/html_node/emacs/Hooks.html
No-Command-791 · 2022-06-28 17:07
>I don't know if opening org-mode buffers trigger the text-mode-hook,
For future reference, it does!