]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/mml2015.el
-
[gnu-emacs] / lisp / gnus / mml2015.el
index 60fddedf899a5847af68ada0fcc96be5b7fe7bb9..774821320f16556052259cf6ee669800cfba8e91 100644 (file)
 
 ;;; Code:
 
-(eval-and-compile
-  (if (locate-library "password-cache")
-      (require 'password-cache)
-    (require 'password)))
-
 (eval-when-compile (require 'cl))
 (require 'mm-decode)
 (require 'mm-util)
 (require 'mml)
 (require 'mml-sec)
+(require 'epg-config)
 
 (defvar mc-pgp-always-sign)
 
 ;; Maybe this should be in eg mml-sec.el (and have a different name).
 ;; Then mml1991 would not need to require mml2015, and mml1991-use
 ;; could be removed.
-(defvar mml2015-use (or
-                    (progn
-                      (ignore-errors (require 'epg-config))
-                      (and (fboundp 'epg-check-configuration)
-                          'epg))
-                    (progn
-                      (let ((abs-file (locate-library "pgg")))
-                        ;; Don't load PGG if it is marked as obsolete
-                        ;; (Emacs 24).
-                        (when (and abs-file
-                                   (not (string-match "/obsolete/[^/]*\\'"
-                                                      abs-file)))
-                          (ignore-errors (require 'pgg))
-                          (and (fboundp 'pgg-sign-region)
-                               'pgg))))
-                    (progn (ignore-errors
-                             (load "mc-toplev"))
-                           (and (fboundp 'mc-encrypt-generic)
-                                (fboundp 'mc-sign-generic)
-                                (fboundp 'mc-cleanup-recipient-headers)
-                                'mailcrypt)))
+(defvar mml2015-use 'epg
   "The package used for PGP/MIME.
 Valid packages include `epg', `pgg' and `mailcrypt'.")
 
@@ -487,14 +463,17 @@ If set, it overrides the setting of `mml2015-sign-with-sender'."
                        (or (y-or-n-p "Sign the message? ")
                            'not))))
             'never)))
-    (mm-with-unibyte-current-buffer
-      (mc-encrypt-generic
-       (or (message-options-get 'message-recipients)
-          (message-options-set 'message-recipients
-                             (mc-cleanup-recipient-headers
-                              (read-string "Recipients: "))))
-       nil nil nil
-       (message-options-get 'message-sender))))
+    (insert
+     (with-temp-buffer
+       (set-buffer-multibyte nil)
+       (mc-encrypt-generic
+       (or (message-options-get 'message-recipients)
+           (message-options-set 'message-recipients
+                                (mc-cleanup-recipient-headers
+                                 (read-string "Recipients: "))))
+       nil nil nil
+       (message-options-get 'message-sender))
+       (buffer-string))))
   (goto-char (point-min))
   (unless (looking-at "-----BEGIN PGP MESSAGE-----")
     (error "Fail to encrypt the message"))
@@ -923,7 +902,7 @@ If set, it overrides the setting of `mml2015-sign-with-sender'."
        (mm-set-handle-multipart-parameter
         mm-security-handle 'gnus-info "Corrupted")
        (throw 'error handle))
-      (setq part (replace-regexp-in-string part "\n" "\r\n")
+      (setq part (replace-regexp-in-string "\n" "\r\n" part)
            signature (mm-get-part signature)
            context (epg-make-context))
       (condition-case error