[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add after-save-hook to a mode
From: |
Philipp Haselwarter |
Subject: |
Re: Add after-save-hook to a mode |
Date: |
Mon, 28 May 2012 11:08:04 +0200 |
User-agent: |
Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.1.50 (gnu/linux) |
Your code modifies `after-save-hook', which is a global variable, every
time `org-mode-hook' is run.
`add-hook' also allows to modify hooks buffer-locally. From its
docstring:
> The optional fourth argument, LOCAL, if non-nil, says to modify
> the hook's buffer-local value rather than its global value.
> This makes the hook buffer-local, and it makes t a member of the
> buffer-local value. That acts as a flag to run the hook
> functions of the global value as well as in the local value.
You can use this to change the value of `after-save-hook' only in those
buffers that run the `org-mode-hook'. This should do:
(add-hook
'org-mode-hook
(lambda nil
(add-hook 'after-save-hook
(lambda nil (org-mobile-push))
nil 'local))) ;Only in the current buffer
--
Philipp Haselwarter