Synch with the semi-1_14 branch.
[elisp/semi.git] / mime-edit.el
index 3ee1983..10dd89a 100644 (file)
@@ -321,7 +321,7 @@ To insert a signature file automatically, call the function
 
     ;;  Pure binary
 
-    ("\\.jpg$"
+    ("\\.jpg$\\|\\.jpeg$"
      "image"   "jpeg"          nil
      "base64"
      "inline"          (("filename" . file)))
@@ -626,7 +626,14 @@ If it is not specified for a major-mode,
                                  ;; XEmacs versions earlier than 21.1.1.
                                  (format " (patch %d)" emacs-patch-level))
                                 (t ""))
-                          " (" xemacs-codename ") ("
+                          " (" xemacs-codename ")"
+                          ;; `xemacs-extra-name' has appeared in the
+                          ;; development version of XEmacs 21.5-b8.
+                          (if (and (boundp 'xemacs-extra-name)
+                                   (symbol-value 'xemacs-extra-name))
+                              (concat " " (symbol-value 'xemacs-extra-name))
+                            "")
+                          " ("
                           system-configuration ")")
                        " (" emacs-version ")"))
            (let ((ver (if (string-match "\\.[0-9]+$" emacs-version)
@@ -753,9 +760,9 @@ Tspecials means any character that matches with it in header must be quoted.")
     (encrypted "Enclose as encrypted"  mime-edit-enclose-pgp-encrypted-region)
     (quote     "Verbatim region"       mime-edit-enclose-quote-region)
     (key       "Insert Public Key"     mime-edit-insert-key)
-    (split     "About split"           mime-edit-set-split)
-    (sign      "About sign"            mime-edit-set-sign)
-    (encrypt   "About encryption"      mime-edit-set-encrypt)
+    (split     "Set splitting"         mime-edit-set-split)
+    (sign      "PGP sign"              mime-edit-set-sign)
+    (encrypt   "PGP encrypt"           mime-edit-set-encrypt)
     (preview   "Preview Message"       mime-edit-preview-message)
     (level     "Toggle transfer-level" mime-edit-toggle-transfer-level))
   "MIME-edit menubar entry.")
@@ -1277,7 +1284,8 @@ Optional argument ENCODING specifies an encoding method such as base64."
        (progn
          (goto-char (1+ (match-end 0)))
          (if (get-text-property (point) 'mime-edit-invisible)
-             (next-single-property-change (point) 'mime-edit-invisible)
+             (or (next-single-property-change (point) 'mime-edit-invisible)
+                 (point-max))
            ;; Move to the end of this text.
            (if (re-search-forward mime-edit-tag-regexp nil 'move)
                ;; Don't forget a multiline tag.
@@ -1388,7 +1396,7 @@ Nil if no such parameter."
        ;; Change value
        (concat (substring ctype 0 (match-beginning 1))
                parameter "=" value
-               (substring contype (match-end 1))
+               (substring ctype (match-end 1))
                opt-fields)
       (concat ctype "; " parameter "=" value opt-fields)
       )))
@@ -1479,7 +1487,7 @@ Optional DELIMITER specifies parameter delimiter (';' by default)."
 
 (defun mime-prompt-for-parameter (parameter)
   "Ask for PARAMETER.
-Parameter must be '(PROMPT CHOICE1 (CHOISE2 ...))."
+Parameter must be '(PROMPT CHOICE1 (CHOICE2...))."
   (let* ((prompt (car parameter))
         (choices (mapcar (function
                           (lambda (e)
@@ -1823,26 +1831,15 @@ Content-Transfer-Encoding: 7bit
          (while (progn (end-of-line) (not (eobp)))
            (insert "\r")
            (forward-line 1))
-         (or (prog1 (smime-sign-buffer)
-               (push nil buffer-undo-list)
-               (ignore-errors (undo)))
+         (or (smime-sign-buffer)
              (throw 'mime-edit-error 'pgp-error)))
        (goto-char beg)
-       (insert (format "--[[multipart/signed;
- boundary=\"%s\"; micalg=sha1;
- protocol=\"application/pkcs7-signature\"][7bit]]
---%s
-" smime-boundary smime-boundary))
-       (goto-char (point-max))
-       (insert (format "\n--%s
-Content-Type: application/pkcs7-signature; name=\"smime.p7s\"
-Content-Transfer-Encoding: base64
-Content-Disposition: attachment; filename=\"smime.p7s\"
-Content-Description: S/MIME Cryptographic Signature
-
-"  smime-boundary))
-       (goto-char (point-max))
-       (insert (format "\n--%s--\n" smime-boundary))))))
+       (if (re-search-forward "^Content-Type:\\s-*" nil t)
+           (let* ((start (match-beginning 0))
+                  (body (buffer-substring (match-end 0) (std11-field-end))))
+             (delete-region start (line-beginning-position 2))
+             (goto-char beg)
+             (insert "--[[" body "][7bit]]\n")))))))
 
 (defun mime-edit-encrypt-smime (beg end boundary)
   (save-excursion
@@ -1864,9 +1861,12 @@ Content-Description: S/MIME Cryptographic Signature
        (or (smime-encrypt-buffer)
            (throw 'mime-edit-error 'pgp-error))
        (goto-char beg)
-       (insert "--[[application/pkcs7-mime; name=\"smime.p7m\"
-Content-Disposition: attachment; filename=\"smime.p7m\"
-Content-Description: S/MIME Encrypted Message][base64]]\n")))))
+       (if (re-search-forward "^Content-Type:\\s-*" nil t)
+           (let* ((start (match-beginning 0))
+                  (body (buffer-substring (match-end 0) (std11-field-end))))
+             (delete-region start (line-beginning-position 2))
+             (goto-char beg)
+             (insert "--[[" body "]]\n")))))))
 
 (defsubst replace-space-with-underline (str)
   (mapconcat (function
@@ -2033,7 +2033,7 @@ Content-Description: S/MIME Encrypted Message][base64]]\n")))))
          (or (looking-at mime-edit-beginning-tag-regexp)
              (eobp)
              (insert (mime-make-text-tag) "\n")))
-       (visible-region beg end)
+       (remove-text-properties beg end '(invisible mime-edit-invisible))
        (goto-char beg))
       (cond
        ((mime-test-content-type contype "message")
@@ -2427,7 +2427,7 @@ Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
          (message (format "Sending %d/%d..."
                           mime-edit-partial-number total))
          (call-interactively command)
-         (message (format "Sending %d/%d... done"
+         (message (format "Sending %d/%d...done"
                           mime-edit-partial-number total)))
        (setq mime-edit-partial-number
              (1+ mime-edit-partial-number)))
@@ -2442,7 +2442,7 @@ Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
       (save-excursion
        (message (format "Sending %d/%d..."
                         mime-edit-partial-number total))
-       (message (format "Sending %d/%d... done"
+       (message (format "Sending %d/%d...done"
                         mime-edit-partial-number total))))))
 
 (defun mime-edit-maybe-split-and-send (&optional cmd)
@@ -2670,14 +2670,15 @@ Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
                         (match-end 0)(point-max) encoding)
                        (setq encoded t
                              encoding nil))))))))
-    (if (or encoded (not not-decode-text))
-       (progn
-         (save-excursion
-           (goto-char (point-min))
-           (while (re-search-forward "\r\n" nil t)
-             (replace-match "\n")))
-         (decode-mime-charset-region (point-min)(point-max)
-                                     (or charset default-mime-charset))))
+    (if (and (eq type 'text)
+            (or encoded (not not-decode-text)))
+       (progn
+         (save-excursion
+           (goto-char (point-min))
+           (while (re-search-forward "\r\n" nil t)
+             (replace-match "\n")))
+         (decode-mime-charset-region (point-min)(point-max)
+                                     (or charset default-mime-charset))))
     (let ((he (if (re-search-forward "^$" nil t)
                  (match-end 0)
                (point-min))))