Explorar el Código

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.
Eric Schulte hace 15 años
padre
commit
9c43017755
Se han modificado 1 ficheros con 12 adiciones y 1 borrados
  1. 12 1
      lisp/ob.el

+ 12 - 1
lisp/ob.el

@@ -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)