(smime-process-region): Use `binary-funcall' instead of
[elisp/semi.git] / pgg-pgp.el
index 4f3fbd7..c005a22 100644 (file)
@@ -25,6 +25,7 @@
 
 ;;; Code:
 
+(require 'mel) ; binary-to-text-funcall, binary-write-decoded-region
 (eval-when-compile (require 'pgg))
 
 (defgroup pgg-pgp ()
@@ -58,6 +59,9 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
 (defvar pgg-pgp-user-id nil
   "PGP ID of your default identity.")
 
+(defvar pgg-pgp-messages-coding-system pgg-messages-coding-system
+  "Coding system used when reading from a PGP external process.")
+
 (defvar pgg-scheme-pgp-instance nil)
 
 ;;;###autoload
@@ -88,10 +92,11 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
       (setenv "PGPPASSFD" "0"))
     (unwind-protect
        (progn
-         (as-binary-process
-          (setq process
-                (apply #'start-process-shell-command "*PGP*" output-buffer
-                       program args)))
+         (setq process
+               (apply #'binary-to-text-funcall
+                      pgg-pgp-messages-coding-system
+                      #'start-process-shell-command "*PGP*" output-buffer
+                      program args))
          (set-process-sentinel process #'ignore)
          (when passphrase
            (process-send-string process (concat passphrase "\n")))
@@ -198,7 +203,7 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
     (unwind-protect
        (progn
          (set-default-file-modes 448)
-         (write-region-as-binary start end orig-file))
+         (binary-write-decoded-region start end orig-file))
       (set-default-file-modes orig-mode))
     (when (stringp signature)
       (copy-file signature (setq signature (concat orig-file ".asc")))
@@ -234,7 +239,8 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
         (args
          (list "+verbose=1" "+batchmode" "+language=us" "-kaf"
                key-file)))
-    (write-region-as-raw-text-CRLF start end key-file)
+    (let ((coding-system-for-write 'raw-text-dos))
+      (write-region start end key-file))
     (pgg-pgp-process-region start end nil pgg-pgp-program args)
     (delete-file key-file)
     (pgg-process-when-success nil)))