From: yamaoka Date: Wed, 7 Dec 2005 07:35:47 +0000 (+0000) Subject: Synch to No Gnus 200512070735. X-Git-Tag: t-gnus-6_17_4-quimby-~190 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=4ef10f5c9a3ff9045ec6c60d56fa27346f66fbbc;p=elisp%2Fgnus.git- Synch to No Gnus 200512070735. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e0b93e8..048cbd3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2005-12-07 Katsumi Yamaoka + + * mm-decode.el (mm-display-external): Use nametemplate (defined in + RFC1524) if it is in mailcap or add a suffix according to + mailcap-mime-extensions when generating a temp filename; postpone + deleting a temp file for 2 seconds for some wrappers, shell + scripts, and so on, which might exit right after having started a + viewer command as a background job. + 2005-12-06 Reiner Steib * nntp.el (nntp-marks-directory): Fix custom group. diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el index d87f104..1805db5 100644 --- a/lisp/mm-decode.el +++ b/lisp/mm-decode.el @@ -755,7 +755,19 @@ external if displayed external." (gnus-map-function mm-file-name-rewrite-functions (file-name-nondirectory filename)) dir)) - (setq file (mm-make-temp-file (expand-file-name "mm." dir)))) + (setq file (mm-make-temp-file (expand-file-name "mm." dir))) + (let ((newname + ;; Use nametemplate (defined in RFC1524) if it is + ;; specified in mailcap. + (if (assoc "nametemplate" mime-info) + (format (assoc "nametemplate" mime-info) file) + ;; Add a suffix according to `mailcap-mime-extensions'. + (concat file (car (rassoc (mm-handle-media-type handle) + mailcap-mime-extensions)))))) + (unless (string-equal file newname) + (when (file-exists-p file) + (rename-file file newname)) + (setq file newname)))) (let ((coding-system-for-write mm-binary-coding-system)) (write-region (point-min) (point-max) file nil 'nomesg)) (message "Viewing with %s" method) @@ -813,6 +825,9 @@ external if displayed external." (ignore-errors (kill-buffer buffer)))))) 'inline) (t + ;; Deleting the temp file should be postponed for some wrappers, + ;; shell scripts, and so on, which might exit right after having + ;; started a viewer command as a background job. (let ((command (mm-mailcap-command method file (mm-handle-type handle)))) (unwind-protect @@ -824,24 +839,38 @@ external if displayed external." shell-command-switch command) (set-process-sentinel (get-buffer-process buffer) - `(lambda (process state) - (when (eq 'exit (process-status process)) - ;; Don't use `ignore-errors'. - (condition-case nil - (delete-file ,file) - (error)) - (condition-case nil - (delete-directory ,(file-name-directory file)) - (error)) - (condition-case nil - (kill-buffer ,buffer) - (error)) - (condition-case nil - ,(macroexpand (list 'mm-handle-set-undisplayer - (list 'quote handle) - nil)) - (error)) - (message "Displaying %s...done" ,command))))) + (lexical-let ;; Don't use `let'. + ;; Function used to remove temp file and directory. + ((fn `(lambda nil + ;; Don't use `ignore-errors'. + (condition-case nil + (delete-file ,file) + (error)) + (condition-case nil + (delete-directory + ,(file-name-directory file)) + (error)))) + ;; Form uses to kill the process buffer and + ;; remove the undisplayer. + (fm `(progn + (kill-buffer ,buffer) + ,(macroexpand + (list 'mm-handle-set-undisplayer + (list 'quote handle) + nil)))) + ;; Message to be issued when the process exits. + (done (format "Displaying %s...done" command)) + ;; In particular, the timer object (which is + ;; a vector in Emacs but is a list in XEmacs) + ;; requires that it is lexically scoped. + (timer (run-at-time 2.0 nil 'ignore))) + (lambda (process state) + (when (eq 'exit (process-status process)) + (if (memq timer timer-list) + (timer-set-function timer fn) + (funcall fn)) + (ignore-errors (eval fm)) + (message "%s" done)))))) (mm-handle-set-external-undisplayer handle (cons file buffer))) (message "Displaying %s..." command))