diff options
Diffstat (limited to 'lisp/gnus/mm-decode.el')
| -rw-r--r-- | lisp/gnus/mm-decode.el | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index 9d0bbdfeb63..108c5056541 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -335,8 +335,11 @@ for instance, text/html parts are very unwanted, and text/richtext are somewhat unwanted, then the value of this variable should be set to: - (\"text/html\" \"text/richtext\")" - :type '(repeat string) + (\"text/html\" \"text/richtext\") + +Adding \"image/.*\" might also be useful. Spammers use it as the +prefered part of multipart/alternative messages." + :type '(repeat regexp) ;; See `mm-preferred-alternative-precedence'. :group 'mime-display) (defcustom mm-tmp-directory @@ -761,7 +764,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) @@ -819,6 +834,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 @@ -830,24 +848,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)) |
