Skip to content

Instantly share code, notes, and snippets.

@lawlist
Last active September 4, 2018 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawlist/303d3000eeb25d4885963ba5514e57d9 to your computer and use it in GitHub Desktop.
Save lawlist/303d3000eeb25d4885963ba5514e57d9 to your computer and use it in GitHub Desktop.
Save an org-archive buffer.
(require 'org)
(setq org-archive-location "~/Dropbox/logs/archive.org::")
(defun org-archive-save-buffer ()
(let ((afile (org-extract-archive-file (org-get-local-archive-location))))
(if (file-exists-p afile)
(let ((buffer (find-file-noselect afile)))
(if (y-or-n-p (format "Save (%s)" buffer))
(with-current-buffer buffer
(save-buffer))
(message "You expressly chose _not_ to save (%s)." buffer)))
(message "Ooops ... (%s) does not exist." afile))))
(add-hook 'org-archive-hook 'org-archive-save-buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment