emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103715: mm-view.el (mm-display-inlin


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103715: 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.
Date: Tue, 22 Mar 2011 13:40:41 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103715
author: Julien Danjou <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Tue 2011-03-22 13:40:41 +0000
message:
  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-mime-copy-part, gnus-mime-inline-part, gnus-insert-mime-button):
   Use `mm-handle-filename'.
  mm-util.el (mm-handle-filename): New function, return the filename of an 
handle.
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/gnus-art.el
  lisp/gnus/gnus-sum.el
  lisp/gnus/mm-util.el
  lisp/gnus/mm-view.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2011-03-19 00:48:04 +0000
+++ b/lisp/gnus/ChangeLog       2011-03-22 13:40:41 +0000
@@ -1,3 +1,20 @@
+2011-03-21  Julien Danjou  <address@hidden>
+
+       * 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-mime-copy-part, gnus-mime-inline-part, gnus-insert-mime-button):
+       Use `mm-handle-filename'.
+
+       * mm-util.el (mm-handle-filename): New function, return the filename of
+       an handle.
+
 2011-03-18  Julien Danjou  <address@hidden>
 
        * gnus-util.el (gnus-buffer-live-p): Simplify gnus-buffer-live-p.

=== modified file 'lisp/gnus/gnus-art.el'
--- a/lisp/gnus/gnus-art.el     2011-03-18 13:45:04 +0000
+++ b/lisp/gnus/gnus-art.el     2011-03-22 13:40:41 +0000
@@ -2811,14 +2811,11 @@
           ((equal (concat "<" cid ">") (mm-handle-id handle))
            (setq file
                  (expand-file-name
-                  (or (mail-content-type-get
-                       (mm-handle-disposition handle) 'filename)
-                      (mail-content-type-get
-                       (setq type (mm-handle-type handle)) 'name)
-                      (concat
-                       (make-temp-name "cid")
-                       (car (rassoc (car type) mailcap-mime-extensions))))
-                  directory))
+                   (or (mm-handle-filename handle)
+                       (concat
+                        (make-temp-name "cid")
+                        (car (rassoc (car (mm-handle-type handle)) 
mailcap-mime-extensions))))
+                   directory))
            (mm-save-part-to-file handle file)
            (throw 'found file))))))))
 
@@ -2835,10 +2832,7 @@
            ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
                 (and (equal (car type) "message/external-body")
                      (or header
-                         (setq file (or (mail-content-type-get type 'name)
-                                        (mail-content-type-get
-                                         (mm-handle-disposition handle)
-                                         'filename))))
+                         (setq file (mm-handle-filename handle)))
                      (or (mm-handle-cache handle)
                          (condition-case code
                              (progn (mm-extern-cache-contents handle) t)
@@ -5043,14 +5037,11 @@
     (let* ((data (get-text-property (point) 'gnus-data))
           (id (get-text-property (point) 'gnus-part))
           (handles gnus-article-mime-handles)
-          (none "(none)")
           (description
            (let ((desc (mm-handle-description data)))
              (when desc
                (mail-decode-encoded-word-string desc))))
-          (filename
-           (or (mail-content-type-get (mm-handle-disposition data) 'filename)
-               none))
+          (filename (or (mm-handle-filename (mm-handle-disposition data)) 
"(none)"))
           (type (mm-handle-media-type data)))
       (unless data
        (error "No MIME part under point"))
@@ -5168,10 +5159,7 @@
   (unless handle
     (setq handle (get-text-property (point) 'gnus-data)))
   (when handle
-    (let ((filename (or (mail-content-type-get (mm-handle-type handle)
-                                              'name)
-                       (mail-content-type-get (mm-handle-disposition handle)
-                                              'filename)))
+    (let ((filename (mm-handle-filename handle))
          contents dont-decode charset coding-system)
       (mm-with-unibyte-buffer
        (mm-insert-part handle)
@@ -5261,12 +5249,7 @@
        (mm-with-unibyte-buffer
          (mm-insert-part handle)
          (setq contents
-               (or (mm-decompress-buffer
-                    (or (mail-content-type-get (mm-handle-type handle)
-                                               'name)
-                        (mail-content-type-get (mm-handle-disposition handle)
-                                               'filename))
-                    nil t)
+               (or (mm-decompress-buffer (mm-handle-filename handle) nil t)
                    (buffer-string))))
        (cond
         ((not arg)
@@ -5671,8 +5654,7 @@
 
 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
   (let ((gnus-tmp-name
-        (or (mail-content-type-get (mm-handle-type handle) 'name)
-            (mail-content-type-get (mm-handle-disposition handle) 'filename)
+        (or (mm-handle-filename handle)
             (mail-content-type-get (mm-handle-type handle) 'url)
             ""))
        (gnus-tmp-type (mm-handle-media-type handle))

=== modified file 'lisp/gnus/gnus-sum.el'
--- a/lisp/gnus/gnus-sum.el     2011-03-17 11:30:27 +0000
+++ b/lisp/gnus/gnus-sum.el     2011-03-22 13:40:41 +0000
@@ -12142,10 +12142,7 @@
                    mm-file-name-rewrite-functions
                    (file-name-nondirectory
                     (or
-                     (mail-content-type-get
-                      (mm-handle-disposition handle) 'filename)
-                     (mail-content-type-get
-                      (mm-handle-type handle) 'name)
+                      (mm-handle-filename handle)
                      (format "%s.%d.%d" gnus-newsgroup-name
                              (cdr gnus-article-current)
                              gnus-summary-save-parts-counter))))

=== modified file 'lisp/gnus/mm-util.el'
--- a/lisp/gnus/mm-util.el      2011-01-25 04:08:28 +0000
+++ b/lisp/gnus/mm-util.el      2011-03-22 13:40:41 +0000
@@ -1667,6 +1667,13 @@
        (when decomp
          (kill-buffer (current-buffer)))))))
 
+(defun mm-handle-filename (handle)
+  "Return filename of HANDLE if any."
+  (or (mail-content-type-get (mm-handle-type handle)
+                             'name)
+      (mail-content-type-get (mm-handle-disposition handle)
+                             'filename)))
+
 (provide 'mm-util)
 
 ;;; mm-util.el ends here

=== modified file 'lisp/gnus/mm-view.el'
--- a/lisp/gnus/mm-view.el      2011-01-25 23:51:40 +0000
+++ b/lisp/gnus/mm-view.el      2011-03-22 13:40:41 +0000
@@ -455,7 +455,7 @@
          (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)))
@@ -565,15 +565,16 @@
                     (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)
       (mm-with-unibyte-buffer
        (mm-insert-part handle)
        (mm-decompress-buffer
-        (or (mail-content-type-get (mm-handle-disposition handle) 'name)
-            (mail-content-type-get (mm-handle-disposition handle) 'filename))
+         (mm-handle-filename handle)
         t t)
        (unless charset
          (setq coding-system (mm-find-buffer-file-coding-system)))
@@ -601,7 +602,10 @@
            (font-lock-support-mode nil)
            ;; I find font-lock a bit too verbose.
            (font-lock-verbose nil))
-       (funcall mode)
+        (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)))
@@ -614,6 +618,9 @@
                       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)))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]