I wanted Emacs to automatically save all buffers after I refiled something, so I followed the bottom-most comment from this question and used
(advice-add 'org-refile :after 'org-save-all-org-buffers)
It works great when the only thing I need to do is refile.
However, if I try to org-copy
something (which does an org-refile
under the hood), or use a custom function which uses org-refile
in some way, I get the following error:
Wrong number of arguments: #[nil "ÀÁ!\210ÂÃÄ\"\210ÅÆ!\203^R^@Ç \210ÀÈ!\207"
[message "Saving all Org-mode buffers..." save-some-buffers t
#[nil "ÀÁ!\207" [derived-mode-p org-mode] 2] featurep org-id org-id-locations-save
"Saving all Org-mode buffers... done"]
3 ("c:/Users/wiuah/.emacs.d/elpa/org-plus-contrib-20160801/org.elc" . 620558) nil], 4
Anyone know what's going on?
org-refile
and then callsorg-save-all-org-buffers
instead of placing anadvice
on a commonly used function? Sure, you can still play around withadvice
and put in exceptions and additional arguments, but why go through the trouble?org-refile
but also saves the buffers after copying/moving, I'll probably accept it.(defun my-org-refile (&optional goto default-buffer rfloc msg) (interactive "P") "Doc-string." (org-refile goto default-buffer rfloc msg) (org-save-all-org-buffers))
If you really want to learn how to do this withadvice
and create exceptions so thatorg-refile
can be used by other functions without throwing an error, then by all means leave the question open for now. Almost everyone except me lovesadvice
-- I use it very sparingly.