I'd like to register an after-save-hook
that is only active in certain buffers that I specify.
For example, assume there are 3 functions currently registered in my after-save-hook
: hook-01
, hook-02
, and hook-03
. In all cases after save-buffer
is called, I'd like hook-01
, hook-02
, and hook-03
to be invoked, and I realize that this is the normal after-save-hook
behavior.
However, in certain buffers and only those buffers, I want an additional hook, special-hook
, to also be called after save-buffer
is invoked, so that in these special buffers, all 4 hooks are run after the buffer is saved.
Is there a way to register a hook function that is added to after-save-hook
only within certain specified buffers?
I control when those special buffers are entered, so I can cause special elisp code to run upon entry into those buffers. I just don't know how to specify a hook that is only valid in a given buffer.