Babel -- fix bug in final deletion of `org-babel-temporary-directory'

Thanks to Noorul Islam for pointing out this issue

* lisp/ob.el (org-babel-remove-temporary-directory): the version of
  `delete-directory' found in files.el can not be assumed to be
  present on all versions, so this copies the recursive behavior of
  that command in such a way that all calls to delete-directory will
  also work with the built-in internal C implementation of that
  function.  This is not overly difficult as all elements of the
  directory can be assumed to be files.
This commit is contained in:
Eric Schulte 2010-08-26 07:22:21 -06:00
parent e3d271ea5b
commit 9c43017755
1 changed files with 12 additions and 1 deletions

View File

@ -1679,7 +1679,18 @@ of `org-babel-temporary-directory'."
(defun org-babel-remove-temporary-directory ()
"Remove `org-babel-temporary-directory' on Emacs shutdown."
(when (boundp 'org-babel-temporary-directory)
(delete-directory org-babel-temporary-directory t)))
;; taken from `delete-directory' in files.el
(mapc (lambda (file)
;; This test is equivalent to
;; (and (file-directory-p fn) (not (file-symlink-p fn)))
;; but more efficient
(if (eq t (car (file-attributes file)))
(delete-directory file)
(delete-file file nil)))
;; We do not want to delete "." and "..".
(directory-files org-babel-temporary-directory 'full
"^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
(delete-directory org-babel-temporary-directory)))
(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)