Signed-off-by: Julien Danjou <julien@danjou.info>
2011-03-21 Julien Danjou <julien@danjou.info>
2011-03-21 Julien Danjou <julien@danjou.info>
- * mm-view.el (mm-display-inline-fontify):
+ * mm-view.el (mm-display-inline-fontify): Make mode optional, and call
+ normal-mode if not set. Set temp buffer unmodified to avoid kill-buffer
+ query.
+ (mm-inline-text): Render normal text with fontification whenever
+ possible.
+
* gnus-sum.el (gnus-summary-save-parts-1):
* gnus-art.el (gnus-article-browse-html-save-cid-content)
(gnus-article-browse-html-parts, gnus-mime-delete-part)
* gnus-sum.el (gnus-summary-save-parts-1):
* gnus-art.el (gnus-article-browse-html-save-cid-content)
(gnus-article-browse-html-parts, gnus-mime-delete-part)
(narrow-to-region (point) (point))
(mm-insert-part handle)
(goto-char (point-max)))
(narrow-to-region (point) (point))
(mm-insert-part handle)
(goto-char (point-max)))
- (insert (mm-decode-string (mm-get-part handle) charset)))
+ (mm-display-inline-fontify handle))
(when (and mm-fill-flowed
(equal type "plain")
(equal (cdr (assoc 'format (mm-handle-type handle)))
(when (and mm-fill-flowed
(equal type "plain")
(equal (cdr (assoc 'format (mm-handle-type handle)))
(face-property 'default prop) (current-buffer))))
(delete-region ,(point-min-marker) ,(point-max-marker)))))))))
(face-property 'default prop) (current-buffer))))
(delete-region ,(point-min-marker) ,(point-max-marker)))))))))
-(defun mm-display-inline-fontify (handle mode)
+(defun mm-display-inline-fontify (handle &optional mode)
+ "Insert HANDLE inline fontifying with MODE.
+If MODE is not set, try to find mode automatically."
(let ((charset (mail-content-type-get (mm-handle-type handle) 'charset))
text coding-system)
(unless (eq charset 'gnus-decoded)
(let ((charset (mail-content-type-get (mm-handle-type handle) 'charset))
text coding-system)
(unless (eq charset 'gnus-decoded)
(font-lock-support-mode nil)
;; I find font-lock a bit too verbose.
(font-lock-verbose nil))
(font-lock-support-mode nil)
;; I find font-lock a bit too verbose.
(font-lock-verbose nil))
+ (setq buffer-file-name (mm-handle-filename handle))
+ (if mode
+ (funcall mode)
+ (normal-mode))
;; The mode function might have already turned on font-lock.
(unless (symbol-value 'font-lock-mode)
(font-lock-fontify-buffer)))
;; The mode function might have already turned on font-lock.
(unless (symbol-value 'font-lock-mode)
(font-lock-fontify-buffer)))
nil)
nil nil nil nil nil 'text-prop))
(setq text (buffer-string))
nil)
nil nil nil nil nil 'text-prop))
(setq text (buffer-string))
+ ;; Set buffer unmodified to avoid confirmation when killing the
+ ;; buffer.
+ (set-buffer-modified-p nil)
(kill-buffer (current-buffer)))
(mm-insert-inline handle text)))
(kill-buffer (current-buffer)))
(mm-insert-inline handle text)))