Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically saving files after refile #9

Open
KirmTwinty opened this issue Dec 17, 2020 · 2 comments
Open

Automatically saving files after refile #9

KirmTwinty opened this issue Dec 17, 2020 · 2 comments

Comments

@KirmTwinty
Copy link
Contributor

First of all thank you for your GTD tutorial, very pedagogic.

I am still learning to handle it and found that saving each time the different org files after refiling was breaking the workflow of the whole process.
Even though saving by hand is a way to make sure that you didn't make a mistake...

Here is how I have done to automatically save the files after refiling:

;; Automatically get the files in "~/Documents/org"
;; with fullpath
(setq org-agenda-files 
      (mapcar 'file-truename 
	      (file-expand-wildcards "~/Documents/org/*.org")))

;; Save the corresponding buffers
(defun gtd-save-org-buffers ()
  "Save `org-agenda-files' buffers without user confirmation.
See also `org-save-all-org-buffers'"
  (interactive)
  (message "Saving org-agenda-files buffers...")
  (save-some-buffers t (lambda () 
			 (when (member (buffer-file-name) org-agenda-files) 
			   t)))
  (message "Saving org-agenda-files buffers... done"))

;; Add it after refile
(advice-add 'org-refile :after
	    (lambda (&rest _)
	      (gtd-save-org-buffers)))
@rougier
Copy link
Owner

rougier commented Dec 18, 2020

You made my day ! I've the same problem and never took time to try to solve it.

@rougier
Copy link
Owner

rougier commented Dec 18, 2020

Could you make a PR for the post with your code (and add your name)?

KirmTwinty added a commit to KirmTwinty/emacs-gtd that referenced this issue Jan 4, 2021
rougier added a commit that referenced this issue Jan 4, 2021
Added `automatic saving after refilling` section rougier/emacs-gtd/#9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants