Closed snan closed 4 years ago
Uh, I think I might be XY probleming it up a bit in here. What I want is a specific font only for Writeroom buffers.
I'd have to look into this a bit more than I have time for right now. Does unbufface
work if you call it with M-x
?
Yes, it does. I just checked.
I haven't been using unbufface too much since I can also call buffer-face-mode directly from M-x.
It's been a while, sorry for that, but I finally got round to solving this issue. The reason buffer-face-mode
wasn't disabled turned out to be something I'd never realised before: minor-mode hooks are run when the minor mode is enabled, but (surprisingly, to me) also when the mode is disabled. So in your case, disabling writeroom-mode
would call unbufface
, but then to-june-b
would be called again immediately after.
I added a hook writeroom-mode-enable-hook
, which is run only when writeroom-mode
is enabled, so you can use that instead. I also added an option writeroom-local-effects
, which can be used to add buffer-local effects to your writeroom-mode
setup. You can add minor mode functions to it, e.g.,:
(add-hook 'writeroom-local-effects 'variable-pitch-mode)
though in your case, that may not be sufficient, because you want to use a particular face. You'd have to write a function (or define a minor mode) that activates buffer-face-mode
with the correct face yourself. Or you could keep the functions you have now and do:
(add-hook 'writeroom-mode-enable-hook 'to-june-b)
(add-hook 'writeroom-mode-disable-hook 'unbufface)
Thanks for reporting this bug and please let me know if you still run into problems.
minor-mode hooks are run when the minor mode is enabled, but (surprisingly, to me) also when the mode is disabled.
I would've never guessed that! Are they also run with the same args?
You'd have to write a function (or define a minor mode) that activates buffer-face-mode with the correct face yourself.
Thank you, I will♥
I would've never guessed that!
I've been using Emacs for over 20 years (huh? Has it really been that long? :open_mouth:) and I never would have guessed either...
Are they also run with the same args?
The functions in a mode hook are run without any arguments, so technically, yeah, they are. :smiley:
In
writeroom--enable
there isWhich is great but I hooked on some other custom stuff into
writeroom-global-effects
and they aren't getting run inwriteroom-global-mode
, only when activating a single writeroom buffer.. Which, ok, they aren't what writeroom calls "global effects", so that tracks. I first tried adding hooks:But for some reason I'm still left in
buffer-face-mode
when I disablewriteroom-mode
. The hook is getting run (I tried putting somemessage
stuff in there, just to check and that worked), so I don't know why. Everything looks cool inwriteroom.el
.