Importing pgnus-0.64
[elisp/gnus.git-] / lisp / gnus-art.el
index 0144dee..4e60965 100644 (file)
@@ -921,7 +921,9 @@ always hide."
          (forward-line 1))))))
 
 (defun article-treat-dumbquotes ()
-  "Translate M******** sm*rtq**t*s into proper text."
+  "Translate M******** sm*rtq**t*s into proper text.
+Note that this function guesses whether a character is a sm*rtq**t* or
+not, so it should only be used interactively."
   (interactive)
   (article-translate-strings gnus-article-dumbquotes-map))
 
@@ -1123,7 +1125,9 @@ If PROMPT (the prefix), prompt for a coding system to use."
 
 (defun article-decode-encoded-words ()
   "Remove encoded-word encoding from headers."
-  (let ((inhibit-point-motion-hooks t) buffer-read-only)
+  (let ((inhibit-point-motion-hooks t)
+       (rfc2047-default-charset gnus-newsgroup-default-charset)
+       buffer-read-only)
     (save-restriction
       (message-narrow-to-head)
       (funcall gnus-decode-header-function (point-min) (point-max)))))
@@ -2283,6 +2287,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
     (gnus-run-hooks 'gnus-tmp-internal-hook)
     (gnus-run-hooks 'gnus-article-prepare-hook)
     (when gnus-display-mime-function
+      (mm-setup-w3)
       (let ((url-standalone-mode (not gnus-plugged)))
        (funcall gnus-display-mime-function)))
     ;; Perform the article display hooks.
@@ -2292,17 +2297,19 @@ If ALL-HEADERS is non-nil, no headers are hidden."
 ;;; Gnus MIME viewing functions
 ;;;
 
-(defvar gnus-mime-button-line-format "%{%([%p. %t%d%n]%)%}%e\n"
+(defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
   "The following specs can be used:
 %t  The MIME type
+%T  MIME type, along with additional info
 %n  The `name' parameter
 %d  The description, if any
 %l  The length of the encoded part
-%p  The part identifier
+%p  The part identifier number
 %e  Dots if the part isn't displayed")
 
 (defvar gnus-mime-button-line-format-alist
   '((?t gnus-tmp-type ?s)
+    (?T gnus-tmp-type-long ?s)
     (?n gnus-tmp-name ?s)
     (?d gnus-tmp-description ?s)
     (?p gnus-tmp-id ?s)
@@ -2379,6 +2386,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
   "Interactively choose a view method for the MIME part under point."
   (interactive)
   (gnus-article-check-buffer)
+  (mm-setup-w3)
   (let ((data (get-text-property (point) 'gnus-data))
        (url-standalone-mode (not gnus-plugged)))
     (mm-interactively-view-part data)))
@@ -2410,6 +2418,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
   "Insert the MIME part under point into the current buffer."
   (interactive "P") ; For compatibility reasons we are not using "z".
   (gnus-article-check-buffer)
+  (mm-setup-w3)
   (let* ((data (get-text-property (point) 'gnus-data))
         contents
         (url-standalone-mode (not gnus-plugged))
@@ -2430,6 +2439,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
   "View the MIME part under point with an external viewer."
   (interactive)
   (gnus-article-check-buffer)
+  (mm-setup-w3)
   (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
         (url-standalone-mode (not gnus-plugged))
         (mm-user-display-methods nil)
@@ -2444,9 +2454,11 @@ If ALL-HEADERS is non-nil, no headers are hidden."
   "View the MIME part under point with an internal viewer."
   (interactive)
   (gnus-article-check-buffer)
+  (mm-setup-w3)
   (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
         (url-standalone-mode (not gnus-plugged))
-        (mm-user-display-methods '(".*"))
+        (mm-user-display-methods '((".*" . inline)))
+        (mm-all-images-fit t)
         (rfc2047-default-charset gnus-newsgroup-default-charset)
         (mm-charset-iso-8859-1-forced gnus-newsgroup-iso-8859-1-forced))
     (if (mm-handle-undisplayer handle)
@@ -2530,28 +2542,29 @@ If ALL-HEADERS is non-nil, no headers are hidden."
       (goto-char point))))
 
 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
-  (let ((gnus-tmp-name (mail-content-type-get (mm-handle-type handle) 'name))
-       (filename (mail-content-type-get (mm-handle-disposition handle)
-                                        'filename))
+  (let ((gnus-tmp-name
+        (or (mail-content-type-get (mm-handle-type handle)
+                                   'name)
+            (mail-content-type-get (mm-handle-disposition handle)
+                                   'filename)
+            ""))
        (gnus-tmp-type (car (mm-handle-type handle)))
-       (gnus-tmp-description (mm-handle-description handle))
+       (gnus-tmp-description (or (mm-handle-description handle)
+                                 ""))
        (gnus-tmp-dots
         (if (if displayed (car displayed)
               (mm-handle-displayed-p handle))
             "" "..."))
-       (gnus-tmp-length (save-excursion
-                          (set-buffer (mm-handle-buffer handle))
+       (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
                           (buffer-size)))
-       b e)
-    (setq gnus-tmp-name (or gnus-tmp-name filename))
-    (setq gnus-tmp-name
-         (if gnus-tmp-name
-             (concat " (" gnus-tmp-name ")")
-           ""))
-    (setq gnus-tmp-description
-         (if gnus-tmp-description
-             (concat " (" gnus-tmp-description ")")
-           ""))
+       gnus-tmp-type-long b e)
+    (when (string-match ".*/" gnus-tmp-name)
+      (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
+    (setq gnus-tmp-type-long (concat gnus-tmp-type
+                                    (and (not (equal gnus-tmp-name ""))
+                                         (concat "; " gnus-tmp-name))))
+    (or (equal gnus-tmp-description "")
+       (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
     (unless (bolp)
       (insert "\n"))
     (setq b (point))
@@ -2564,11 +2577,25 @@ If ALL-HEADERS is non-nil, no headers are hidden."
                 article-type annotation
                 gnus-data ,handle))
     (setq e (point))
-    (widget-convert-button 'link b e :action 'gnus-widget-press-button
-                          :button-keymap gnus-mime-button-map)))
+    (widget-convert-button 'link b e
+                          :mime-handle handle
+                          :action 'gnus-widget-press-button
+                          :button-keymap gnus-mime-button-map
+                          :help-echo
+                          (lambda (widget)
+                            ;; Needed to properly clear the message
+                            ;; due to a bug in wid-edit
+                            (setq help-echo-owns-message t)
+                            (format
+                             "Click to %s the MIME part; %s for more options"
+                             (if (mm-handle-displayed-p
+                                  (widget-get widget :mime-handle))
+                                 "hide" "show")
+                             (if gnus-xemacs "button3" "mouse-3"))))))
 
 (defun gnus-widget-press-button (elems el)
   (goto-char (widget-get elems :from))
+  (mm-setup-w3)
   (let ((url-standalone-mode (not gnus-plugged)))
     (gnus-article-press-button)))
 
@@ -2576,9 +2603,13 @@ If ALL-HEADERS is non-nil, no headers are hidden."
   "Insert MIME buttons in the buffer."
   (save-excursion
     (save-selected-window
-      (let ((window (get-buffer-window gnus-article-buffer)))
+      (let ((window (get-buffer-window gnus-article-buffer))
+           (point (point)))
        (when window
-         (select-window window)))
+         (select-window window)
+         ;; We have to do this since selecting the window
+         ;; may change the point.  So we set the window point.
+         (set-window-point window point)))
       (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
             handle name type b e display)
        (unless ihandles
@@ -2737,7 +2768,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
            (gnus-add-text-properties
             (setq from (point))
             (progn
-              (insert (format "[%c] %-18s"
+              (insert (format "(%c) %-18s"
                               (if (equal handle preferred) ?* ? )
                               (if (stringp (car handle))
                                   (car handle)