From 3110fa99bb4b4d4d007276a6b5d1022af0a6c08e Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Thu, 19 May 2022 22:59:35 -0400 Subject: [PATCH] Avoid saving currently being edited org-mode buffer --- global.org | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/global.org b/global.org index ade255b..e81bbc3 100644 --- a/global.org +++ b/global.org @@ -1131,9 +1131,20 @@ #+end_src *** Automate saving - This will take care of most of the other stuff + Save all org buffers with the auto-save-hook. Avoid saving the + buffer that is currently being edited; doing so it removes + trailing whitespace, which is undesirable while writing. #+begin_src emacs-lisp - (add-hook 'auto-save-hook 'org-save-all-org-buffers) + (defun org-save-all-org-buffers-except-current () + "Save all Org buffers without user confirmation." + (interactive) + (message "Saving all Org buffers...") + (let ((buffer (current-buffer))) + (save-some-buffers t (lambda () (and (not (eq (current-buffer) buffer)) (derived-mode-p 'org-mode))))) + (when (featurep 'org-id) (org-id-locations-save)) + (message "Saving all Org buffers... done")) + + (add-hook 'auto-save-hook 'org-save-all-org-buffers-except-current) #+end_src *** Reverting stuff from orgzly #+begin_src emacs-lisp