diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-28 07:34:08 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-28 07:41:16 -0600 |
commit | f6ccee2568a60d855bca5d667128e889bbbbf9c5 (patch) | |
tree | 9d660c93211451fda5762b7d147f008283042312 | |
parent | 4d318e4499f31c19f213400e602470a05ea046b3 (diff) | |
download | org-mode-f6ccee2568a60d855bca5d667128e889bbbbf9c5.tar.gz |
ob-tangle: org-babel-post-tangle-hook no longer kills the current buffer
* lisp/ob-tangle.el (org-babel-find-file-noselect-refresh): finds a
file ensuing that the latest changes on disk are represented
(org-babel-with-temp-filebuffer): now only kills the buffer of the
tangled file, and doesn't kill said buffer if the file is already
being visited
-rw-r--r-- | lisp/ob-tangle.el | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index be4e53e..0a9aae2 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -53,18 +53,28 @@ then the name of the language is used." :group 'org-babel :type 'hook) +(defun org-babel-find-file-noselect-refresh (file) + "Find file ensuring that the latest changes on disk are +represented in the file." + (find-file-noselect file) + (with-current-buffer (get-file-buffer file) + (revert-buffer t t t))) + (defmacro org-babel-with-temp-filebuffer (file &rest body) "Open FILE into a temporary buffer execute BODY there like `progn', then kill the FILE buffer returning the result of evaluating BODY." (declare (indent 1)) (let ((temp-result (make-symbol "temp-result")) - (temp-file (make-symbol "temp-file"))) + (temp-file (make-symbol "temp-file")) + (visited-p (make-symbol "already-visited"))) `(let (,temp-result ,temp-file) - (find-file-noselect ,file) - (setf ,temp-file (current-buffer)) - (setf ,temp-result (progn ,@body)) - (kill-buffer ,temp-file) + (setq ,visited-p (get-file-buffer ,file )) + (org-babel-find-file-noselect-refresh ,file) + (setf ,temp-file (get-file-buffer ,file)) + (with-current-buffer ,temp-file + (setf ,temp-result (progn ,@body))) + (unless ,visited-p (kill-buffer ,temp-file)) ,temp-result))) ;;;###autoload |