* mime-play.el (mime-play-delete-file-immediately): New user option.
authorari <ari>
Sun, 14 Dec 2003 12:56:11 +0000 (12:56 +0000)
committerari <ari>
Sun, 14 Dec 2003 12:56:11 +0000 (12:56 +0000)
(mime-mailcap-method-sentinel): Use it.
(mime-mailcap-delete-played-files): New function; set up for
`kill-emacs-hook'.

ChangeLog
mime-play.el

index d543913..9b6ff0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-12-12  ARISAWA Akihiro  <ari@mbf.sphere.ne.jp>
+
+       * mime-play.el (mime-play-delete-file-immediately): New user option.
+       (mime-mailcap-method-sentinel): Use it.
+       (mime-mailcap-delete-played-files): New function; set up for
+       `kill-emacs-hook'.
+
 2002-05-18  ARISAWA Akihiro  <ari@mbf.sphere.ne.jp>
 
        * mime-play.el (mime-activate-mailcap-method): Don't use
index 846f8cc..32283ad 100644 (file)
@@ -43,6 +43,11 @@ If t, it means current directory."
   :type '(choice (const :tag "Current directory" t)
                 (directory)))
 
+(defcustom mime-play-delete-file-immediately t
+  "If non-nil, delete played file immediately."
+  :group 'mime-view
+  :type 'boolean)
+
 (defvar mime-play-find-every-situations t
   "*Find every available situations if non-nil.")
 
@@ -159,13 +164,19 @@ specified, play as it.  Default MODE is \"play\"."
       (set-process-sentinel process 'mime-mailcap-method-sentinel))))
 
 (defun mime-mailcap-method-sentinel (process event)
-  (let ((file (cdr (assq process mime-mailcap-method-filename-alist))))
-    (when (file-exists-p file)
-      (ignore-errors
-       (delete-file file)
-       (delete-directory (file-name-directory file)))))
-  (remove-alist 'mime-mailcap-method-filename-alist process)
-  (message "%s %s" process event))
+  (when mime-play-delete-file-immediately
+    (let ((file (cdr (assq process mime-mailcap-method-filename-alist))))
+      (if (file-exists-p file)
+         (delete-file file)))
+    (remove-alist 'mime-mailcap-method-filename-alist process))
+  (message (format "%s %s" process event)))
+
+(defun mime-mailcap-delete-played-files ()
+  (dolist (elem mime-mailcap-method-filename-alist)
+    (when (file-exists-p (cdr elem))
+      (delete-file (cdr elem)))))
+
+(add-hook 'kill-emacs-hook 'mime-mailcap-delete-played-files)
 
 (defvar mime-echo-window-is-shared-with-bbdb
   (module-installed-p 'bbdb)