]> git.eshelyaron.com Git - emacs.git/commitdiff
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-265
authorMiles Bader <miles@gnu.org>
Fri, 5 May 2006 01:53:06 +0000 (01:53 +0000)
committerMiles Bader <miles@gnu.org>
Fri, 5 May 2006 01:53:06 +0000 (01:53 +0000)
Merge from gnus--rel--5.10

Patches applied:

 * gnus--rel--5.10  (patch 99-100)

   - Merge from emacs--devo--0
   - Update from CVS

lisp/gnus/ChangeLog
lisp/gnus/gnus-art.el
lisp/gnus/mm-decode.el

index cecc180f522dce149f8052bbafbfce34c60d289d..7f0f248c7cfda1ec29851364f4973610dadf6906 100644 (file)
@@ -1,3 +1,24 @@
+2006-05-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * mm-decode.el (mm-dissect-buffer): Remove spurious double assignment.
+       (mm-copy-to-buffer): Use with-current-buffer.
+       (mm-display-part): Simplify.
+       (mm-inlinable-p): Add optional arg `type'.
+
+       * gnus-art.el (gnus-mime-view-part-as-type): Add optional PRED
+       argument.
+       (gnus-mime-view-part-externally, gnus-mime-view-part-internally):
+       Try harder to show the attachment internally or externally using
+       gnus-mime-view-part-as-type.
+
+2006-05-04  Reiner Steib  <Reiner.Steib@gmx.de>
+
+       * gnus-art.el (gnus-mime-view-part-as-type-internal): Try to fetch
+       `filename' from Content-Disposition if Content-Type doesn't
+       provide `name'.
+       (gnus-mime-view-part-as-type): Set default instead of
+       initial-input.
+
 2006-04-28  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * mm-uu.el (mm-uu-pgp-encrypted-extract-1): Assume buffer is made
index 7e3b843d500085a5a6a712da26311e23013d1a12..208103f805dfa5e85caf7eb246affd7198d2b7b5 100644 (file)
@@ -4317,21 +4317,29 @@ Deleting parts may malfunction or destroy the article; continue? ")
 
 (defun gnus-mime-view-part-as-type-internal ()
   (gnus-article-check-buffer)
-  (let* ((name (mail-content-type-get
-               (mm-handle-type (get-text-property (point) 'gnus-data))
-               'name))
+  (let* ((handle (get-text-property (point) 'gnus-data))
+        (name (or
+               ;; Content-Type: foo/bar; name=...
+               (mail-content-type-get (mm-handle-type handle) 'name)
+               ;; Content-Disposition: attachment; filename=...
+               (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
         (def-type (and name (mm-default-file-encoding name))))
     (and def-type (cons def-type 0))))
 
-(defun gnus-mime-view-part-as-type (&optional mime-type)
-  "Choose a MIME media type, and view the part as such."
+(defun gnus-mime-view-part-as-type (&optional mime-type pred)
+  "Choose a MIME media type, and view the part as such.
+If non-nil, PRED is a predicate to use during completion to limit the
+available media-types."
   (interactive)
   (unless mime-type
-    (setq mime-type (completing-read
-                    "View as MIME type: "
-                    (mapcar #'list (mailcap-mime-types))
-                    nil nil
-                    (gnus-mime-view-part-as-type-internal))))
+    (setq mime-type
+         (let ((default (gnus-mime-view-part-as-type-internal)))
+           (completing-read
+            (format "View as MIME type (default %s): "
+                    (car default))
+            (mapcar #'list (mailcap-mime-types))
+            pred nil nil nil
+            (car default)))))
   (gnus-article-check-buffer)
   (let ((handle (get-text-property (point) 'gnus-data)))
     (when handle
@@ -4511,12 +4519,18 @@ specified charset."
         (mm-inlined-types nil)
         (mail-parse-charset gnus-newsgroup-charset)
         (mail-parse-ignored-charsets
-         (save-excursion (set-buffer gnus-summary-buffer)
-                         gnus-newsgroup-ignored-charsets)))
-    (when handle
-      (if (mm-handle-undisplayer handle)
-         (mm-remove-part handle)
-       (mm-display-part handle)))))
+          (with-current-buffer gnus-summary-buffer
+            gnus-newsgroup-ignored-charsets))
+         (type (mm-handle-media-type handle))
+         (method (mailcap-mime-info type))
+         (mm-enable-external t))
+    (if (not (stringp method))
+       (gnus-mime-view-part-as-type
+        nil (lambda (type) (stringp (mailcap-mime-info type))))
+      (when handle
+       (if (mm-handle-undisplayer handle)
+           (mm-remove-part handle)
+         (mm-display-part handle))))))
 
 (defun gnus-mime-view-part-internally (&optional handle)
   "View the MIME part under point with an internal viewer.
@@ -4528,13 +4542,16 @@ If no internal viewer is available, use an external viewer."
         (mm-inline-large-images t)
         (mail-parse-charset gnus-newsgroup-charset)
         (mail-parse-ignored-charsets
-         (save-excursion (set-buffer gnus-summary-buffer)
-                         gnus-newsgroup-ignored-charsets))
+         (with-current-buffer gnus-summary-buffer
+           gnus-newsgroup-ignored-charsets))
         (inhibit-read-only t))
-    (when handle
-      (if (mm-handle-undisplayer handle)
-         (mm-remove-part handle)
-       (mm-display-part handle)))))
+    (if (not (mm-inlinable-p handle))
+        (gnus-mime-view-part-as-type
+         nil (lambda (type) (mm-inlinable-p handle type)))
+      (when handle
+       (if (mm-handle-undisplayer handle)
+           (mm-remove-part handle)
+         (mm-display-part handle))))))
 
 (defun gnus-mime-action-on-part (&optional action)
   "Do something with the MIME attachment at \(point\)."
index b79e081f0e1ceda743e6ed03007829d522a9af70..c5fd5d3c258d2a191a950c2509b09fd10b4bd689 100644 (file)
@@ -562,7 +562,7 @@ Postpone undisplaying of viewers for types in
           description)
        (setq type (split-string (car ctl) "/"))
        (setq subtype (cadr type)
-             type (pop type))
+             type (car type))
        (setq
         result
         (cond
@@ -641,16 +641,15 @@ Postpone undisplaying of viewers for types in
 
 (defun mm-copy-to-buffer ()
   "Copy the contents of the current buffer to a fresh buffer."
-  (save-excursion
     (let ((obuf (current-buffer))
          beg)
       (goto-char (point-min))
       (search-forward-regexp "^\n" nil t)
       (setq beg (point))
-      (set-buffer
+    (with-current-buffer
        ;; Preserve the data's unibyteness (for url-insert-file-contents).
        (let ((default-enable-multibyte-characters (mm-multibyte-p)))
-        (generate-new-buffer " *mm*")))
+          (generate-new-buffer " *mm*"))
       (insert-buffer-substring obuf beg)
       (current-buffer))))
 
@@ -701,7 +700,8 @@ external if displayed external."
                  (forward-line 1)
                  (mm-insert-inline handle (mm-get-part handle))
                  'inline)
-             (if (and method ;; If nil, we always use "save".
+             (setq external
+                    (and method ;; If nil, we always use "save".
                       (stringp method) ;; 'mailcap-save-binary-file
                       (or (eq mm-enable-external t)
                           (and (eq mm-enable-external 'ask)
@@ -714,9 +714,7 @@ external if displayed external."
                                      (concat
                                       " \"" (format method filename) "\"")
                                    "")
-                                 "? ")))))
-                 (setq external t)
-               (setq external nil))
+                                    "? "))))))
              (if external
                  (mm-display-external
                   handle (or method 'mailcap-save-binary-file))
@@ -1019,10 +1017,12 @@ external if displayed external."
              methods nil)))
     result))
 
-(defun mm-inlinable-p (handle)
-  "Say whether HANDLE can be displayed inline."
+(defun mm-inlinable-p (handle &optional type)
+  "Say whether HANDLE can be displayed inline.
+TYPE is the mime-type of the object; it defaults to the one given
+in HANDLE."
+  (unless type (setq type (mm-handle-media-type handle)))
   (let ((alist mm-inline-media-tests)
-       (type (mm-handle-media-type handle))
        test)
     (while alist
       (when (string-match (caar alist) type)