* mailcap.el (mailcap-parse-args-syntax-table)
[gnus] / lisp / mm-decode.el
index 977bb8a..19a99e4 100644 (file)
@@ -1,5 +1,6 @@
 ;;; mm-decode.el --- Functions for decoding MIME things
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002,
+;;        2003 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;     MORIOKA Tomohiko <morioka@jaist.ac.jp>
@@ -110,7 +111,7 @@ The defined renderer types are:
 `links': using links;
 `lynx' : using lynx;
 `html2text' : using html2text;
-`nil'  : using external viewer."
+nil    : using external viewer."
   :type '(choice (const w3)
                 (const w3m)
                 (const links)
@@ -133,13 +134,14 @@ the documentation for the option `mm-w3m-safe-url-regexp'."
   :group 'mime-display)
 
 (defcustom mm-w3m-safe-url-regexp "\\`cid:"
-  "Regexp that matches safe url names.  Some HTML mails might have a
-trick of spammers using <img> tags.  It is likely to be intended to
-verify whether you have read the mail.  You can prevent your personal
-informations from leaking by setting this to the regexp which matches
-the safe url names.  The value of the variable `w3m-safe-url-regexp'
-will be bound with this value.  You may set this value to nil if you
-consider all the urls to be safe."
+  "Regexp that matches safe url names.
+Some HTML mails might have a trick of spammers using <img> tags.
+It is likely to be intended to verify whether you have read the
+mail.  You can prevent your personal informations from leaking by
+setting this to the regexp which matches the safe url names.  The
+value of the variable `w3m-safe-url-regexp' will be bound with
+this value.  You may set this value to nil if you consider all
+urls to be safe."
   :type '(choice (regexp :tag "Regexp")
                 (const :tag "All URLs are safe" nil))
   :group 'mime-display)
@@ -307,9 +309,11 @@ to:
   :group 'mime-display)
 
 (defcustom mm-tmp-directory
-  (cond ((fboundp 'temp-directory) (temp-directory))
-       ((boundp 'temporary-file-directory) temporary-file-directory)
-       ("/tmp/"))
+  (if (fboundp 'temp-directory)
+      (temp-directory)
+    (if (boundp 'temporary-file-directory)
+       temporary-file-directory
+      "/tmp/"))
   "Where mm will store its temporary files."
   :type 'directory
   :group 'mime-display)
@@ -332,10 +336,10 @@ Ready-made functions include
 `upcase-initials'.")
 
 (defvar mm-path-name-rewrite-functions nil
-  "*List of functions used for rewriting path names of MIME parts.
-This is used when viewing parts externally , and is meant for
-transforming the path name so that non-compliant programs can
-find the file where it's saved.
+  "*List of functions for rewriting the full file names of MIME parts.
+This is used when viewing parts externally, and is meant for
+transforming the absolute name so that non-compliant programs can find
+the file where it's saved.
 
 Each function takes a file name as input and returns a file name.")
 
@@ -355,7 +359,6 @@ If not set, `default-directory' will be used."
 
 ;;; Internal variables.
 
-(defvar mm-dissection-list nil)
 (defvar mm-last-shell-command "")
 (defvar mm-content-id-alist nil)
 (defvar mm-postponed-undisplay-list nil)
@@ -382,7 +385,7 @@ If not set, `default-directory' will be used."
 (defcustom mm-verify-option 'never
   "Option of verifying signed parts.
 `never', not verify; `always', always verify;
-`known', only verify known protocols. Otherwise, ask user."
+`known', only verify known protocols.  Otherwise, ask user."
   :type '(choice (item always)
                 (item never)
                 (item :tag "only known protocols" known)
@@ -400,7 +403,7 @@ If not set, `default-directory' will be used."
 (defcustom mm-decrypt-option nil
   "Option of decrypting encrypted parts.
 `never', not decrypt; `always', always decrypt;
-`known', only decrypt known protocols. Otherwise, ask user."
+`known', only decrypt known protocols.  Otherwise, ask user."
   :type '(choice (item always)
                 (item never)
                 (item :tag "only known protocols" known)
@@ -456,8 +459,9 @@ The original alist is not modified.  See also `destructive-alist-to-plist'."
          (throw 'found t))))))
 
 (defun mm-handle-set-external-undisplayer (handle function)
-  "Set the undisplayer for this handle; postpone undisplaying of viewers
-for types in mm-keep-viewer-alive-types."
+  "Set the undisplayer for HANDLE to FUNCTION.
+Postpone undisplaying of viewers for types in
+`mm-keep-viewer-alive-types'."
   (if (mm-keep-viewer-alive-p handle)
       (let ((new-handle (copy-sequence handle)))
        (mm-handle-set-undisplayer new-handle function)
@@ -552,16 +556,8 @@ for types in mm-keep-viewer-alive-types."
            (if (equal "text/plain" (car ctl))
                (assoc 'format ctl)
              t))
-    (let ((res (mm-make-handle
-               (mm-copy-to-buffer) ctl cte nil cdl description nil id)))
-      (push (car res) mm-dissection-list)
-      res)))
-
-(defun mm-remove-all-parts ()
-  "Remove all MIME handles."
-  (interactive)
-  (mapcar 'mm-remove-part mm-dissection-list)
-  (setq mm-dissection-list nil))
+    (mm-make-handle
+     (mm-copy-to-buffer) ctl cte nil cdl description nil id)))
 
 (defun mm-dissect-multipart (ctl)
   (goto-char (point-min))
@@ -1007,8 +1003,8 @@ external if displayed external."
 
 (defun mm-file-name-replace-whitespace (file-name)
   "Replace whitespace characters in FILE-NAME with underscores.
-Set `mm-file-name-replace-whitespace' to any other string if you do not
-like underscores."
+Set the option `mm-file-name-replace-whitespace' to any other
+string if you do not like underscores."
   (let ((s (or mm-file-name-replace-whitespace "_")))
     (while (string-match "\\s-" file-name)
       (setq file-name (replace-match s t t file-name))))
@@ -1270,7 +1266,7 @@ If RECURSIVE, search recursively."
                    (if notp
                        (not (equal (car ctl) type))
                      (equal (car ctl) type)))
-             (setq result (buffer-substring (point-min) (point-max)))))))
+             (setq result (buffer-string))))))
       (forward-line 1)
       (setq start (point)))
     (when (and (not result) start)
@@ -1283,16 +1279,16 @@ If RECURSIVE, search recursively."
                  (if notp
                      (not (equal (car ctl) type))
                    (equal (car ctl) type)))
-           (setq result (buffer-substring (point-min) (point-max)))))))
+           (setq result (buffer-string))))))
     result))
 
 (defvar mm-security-handle nil)
 
 (defsubst mm-set-handle-multipart-parameter (handle parameter value)
   ;; HANDLE could be a CTL.
-  (if handle
-      (put-text-property 0 (length (car handle)) parameter value
-                        (car handle))))
+  (when handle
+    (put-text-property 0 (length (car handle)) parameter value
+                      (car handle))))
 
 (defun mm-possibly-verify-or-decrypt (parts ctl)
   (let ((type (car ctl))
@@ -1325,25 +1321,26 @@ If RECURSIVE, search recursively."
                      protocols nil)
              (setq protocols (cdr protocols))))))
       (setq func (nth 1 (assoc protocol mm-verify-function-alist)))
-      (if (cond
-          ((eq mm-verify-option 'never) nil)
-          ((eq mm-verify-option 'always) t)
-          ((eq mm-verify-option 'known)
-           (and func
-                (or (not (setq functest
-                               (nth 3 (assoc protocol
-                                             mm-verify-function-alist))))
-                    (funcall functest parts ctl))))
-          (t (y-or-n-p
+      (when (cond
+            ((eq mm-verify-option 'never) nil)
+            ((eq mm-verify-option 'always) t)
+            ((eq mm-verify-option 'known)
+             (and func
+                  (or (not (setq functest
+                                 (nth 3 (assoc protocol
+                                               mm-verify-function-alist))))
+                      (funcall functest parts ctl))))
+            (t
+             (y-or-n-p
               (format "Verify signed (%s) part? "
                       (or (nth 2 (assoc protocol mm-verify-function-alist))
                           (format "protocol=%s" protocol))))))
-         (save-excursion
-           (if func
-               (funcall func parts ctl)
-             (mm-set-handle-multipart-parameter
-              mm-security-handle 'gnus-details
-              (format "Unknown sign protocol (%s)" protocol))))))
+       (save-excursion
+         (if func
+             (funcall func parts ctl)
+           (mm-set-handle-multipart-parameter
+            mm-security-handle 'gnus-details
+            (format "Unknown sign protocol (%s)" protocol))))))
      ((equal subtype "encrypted")
       (unless (setq protocol
                    (mm-handle-multipart-ctl-parameter ctl 'protocol))
@@ -1356,25 +1353,26 @@ If RECURSIVE, search recursively."
                      parts nil)
              (setq parts (cdr parts))))))
       (setq func (nth 1 (assoc protocol mm-decrypt-function-alist)))
-      (if (cond
-          ((eq mm-decrypt-option 'never) nil)
-          ((eq mm-decrypt-option 'always) t)
-          ((eq mm-decrypt-option 'known)
-           (and func
-                (or (not (setq functest
-                               (nth 3 (assoc protocol
-                                             mm-decrypt-function-alist))))
-                    (funcall functest parts ctl))))
-          (t (y-or-n-p
+      (when (cond
+            ((eq mm-decrypt-option 'never) nil)
+            ((eq mm-decrypt-option 'always) t)
+            ((eq mm-decrypt-option 'known)
+             (and func
+                  (or (not (setq functest
+                                 (nth 3 (assoc protocol
+                                               mm-decrypt-function-alist))))
+                      (funcall functest parts ctl))))
+            (t
+             (y-or-n-p
               (format "Decrypt (%s) part? "
                       (or (nth 2 (assoc protocol mm-decrypt-function-alist))
                           (format "protocol=%s" protocol))))))
-         (save-excursion
-           (if func
-               (setq parts (funcall func parts ctl))
-             (mm-set-handle-multipart-parameter
-              mm-security-handle 'gnus-details
-              (format "Unknown encrypt protocol (%s)" protocol))))))
+       (save-excursion
+         (if func
+             (setq parts (funcall func parts ctl))
+           (mm-set-handle-multipart-parameter
+            mm-security-handle 'gnus-details
+            (format "Unknown encrypt protocol (%s)" protocol))))))
      (t nil))
     parts))