I want to write a minor which evaluates some code in the buffer after saving a file. I activate after-save-hook for this mode:
(add-hook 'my-minor-mode-name-hook #'(lambda () (add-hook 'after-save-hook #'a-func-from-my-minor-mode))
Everything works as intended until I disable the minor mode with the command
my-minor-mode-name. I get the message that the mode has been disabled but
after-save-hook is still active (although evaluating
after-save-hook in the buffer indicates that
a-func-from-my-minor-mode is not on the list).
I want a behaviour where disabling the minor mode removes automatically the hook -- how should I fix that?