--- mm-decode.el~ 2013-01-30 09:41:37.287257600 +0000 +++ mm-decode.el 2013-02-27 09:20:30.267956900 +0000 @@ -814,6 +814,8 @@ (declare-function gnus-configure-windows "gnus-win" (setting &optional force)) (defvar mailcap-mime-extensions) ; mailcap-mime-info autoloads +(defvar write-point) + (defun mm-display-external (handle method) "Display HANDLE using METHOD." (let ((outbuf (current-buffer))) @@ -950,9 +952,33 @@ method file (mm-handle-type handle)))) (unwind-protect (progn + (setq buffer (generate-new-buffer " *mm*")) + (let (wp) + (with-current-buffer outbuf + (let ((point (point))) + (forward-line 2) + (setq wp (point)) + (goto-char point))) + (with-current-buffer buffer + (set (make-local-variable 'write-point) wp) + (set (make-local-variable 'after-change-functions) + `((lambda (st nd len) + (when (buffer-live-p ,outbuf) + (let (wp text) + (with-current-buffer ,buffer + (setq wp write-point + text (buffer-substring st nd) + write-point (+ wp (- nd st)))) + (with-current-buffer ,outbuf + (let ((buffer-read-only nil) + (point (point))) + (goto-char wp) + (mm-insert-inline + ',handle (with-current-buffer ,buffer + (buffer-substring st nd))) + (goto-char point)))))))))) (start-process "*display*" - (setq buffer - (generate-new-buffer " *mm*")) + buffer shell-file-name shell-command-switch command) (set-process-sentinel @@ -977,15 +1003,6 @@ (condition-case nil (delete-directory (file-name-directory file)) (error)) - (when (buffer-live-p outbuf) - (with-current-buffer outbuf - (let ((buffer-read-only nil) - (point (point))) - (forward-line 2) - (mm-insert-inline - handle (with-current-buffer buffer - (buffer-string))) - (goto-char point)))) (when (buffer-live-p buffer) (kill-buffer buffer))) (message "Displaying %s...done" command)))))