summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2010-12-08 10:11:49 +0000
committerDan Davison <dandavison7@gmail.com>2010-12-08 10:11:49 +0000
commitc6a945e82cd0e2f4500fc2d468c45a80d5121cde (patch)
tree5d65e1d06988935dbbbe63a8c8ffe9a8c992a7b4
parentbe882617ad907400d7935d1b646aa1c5bb0c1d57 (diff)
downloadorg-mode-c6a945e82cd0e2f4500fc2d468c45a80d5121cde.tar.gz
babel: Handle errors when temporary directory is on a different partition
* lisp/ob.el (org-babel-remove-temporary-directory): Handle exception with message informing of failure to remove directory. Thanks to Antti Kaihola for the bug report: http://thread.gmane.org/gmane.emacs.orgmode/34394 From: Antti Kaihola <akaihola <at> gmail.com> Subject: Can't close Emacs+org-mode if /tmp and /home on different partitions Newsgroups: gmane.emacs.orgmode Date: 2010-12-02 08:33:28 GMT (6 days, 1 hour and 22 minutes ago) I have /tmp on my root partition and a separate partition for /home. When trying to close an Emacs session which is using org-mode, I get this error: move-file-to-trash: Non-regular file: Is a directory, /tmp/babel-XXXXXXX (where XXXXXXX are random characters). I tracked down the problem to org-babel-remove-temporary-directory which ob.el adds to kill-emacs-hook. It tries to remove the temporary directory using delete-directory, which in turn tries to move the directory (by renaming) into trash, which is in my home directory. I added this to my ~/.emacs.d/init.el: (custom-set-variables '(temporary-file-directory "/home/akaihola/tmp/")) and closing Emacs works correctly again. However, since my init.el is part of emacs-starter-kit which I update frequently, I'd prefer not to modify that file. Unfortunately the customization hook emacs-starter-kit provides (~/.emacs.d/custom.el) is loaded too late to affect the temporary directory. I'm running emacs-snapshot 1:20090909-1 in Ubuntu 10.10. Looks like this is really an Emacs bug and is already fixed: http://groups.google.com/group/gnu.emacs.bug/browse_thread/thread/0446b8684a8ef504
-rw-r--r--lisp/ob.el27
1 files changed, 16 insertions, 11 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index fe392d9..4a934ac 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1942,17 +1942,22 @@ of `org-babel-temporary-directory'."
(when (and (boundp 'org-babel-temporary-directory)
(file-exists-p org-babel-temporary-directory))
;; 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)))
- ;; We do not want to delete "." and "..".
- (directory-files org-babel-temporary-directory 'full
- "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
- (delete-directory org-babel-temporary-directory)))
+ (condition-case nil
+ (progn
+ (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)))
+ ;; We do not want to delete "." and "..".
+ (directory-files org-babel-temporary-directory 'full
+ "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
+ (delete-directory org-babel-temporary-directory))
+ (error
+ (message "Failed to remove temporary Org-babel directory %s"
+ org-babel-temporary-directory)))))
(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)