* pgg-gpg.el (pgg-gpg-process-region): Undo the last change.
[elisp/semi.git] / pgg-gpg.el
index dfd9ca7..191c90b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; pgg-gpg.el --- GnuPG support for PGG.
 
-;; Copyright (C) 1999,2000 Daiki Ueno
+;; Copyright (C) 1999,2000 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Created: 1999/10/28
@@ -25,6 +25,7 @@
 
 ;;; Code:
 
+(require 'mel) ; binary-to-text-funcall
 (eval-when-compile (require 'pgg))
 
 (defgroup pgg-gpg ()
@@ -47,6 +48,9 @@
 (defvar pgg-gpg-user-id nil
   "GnuPG ID of your default identity.")
 
+(defvar pgg-gpg-messages-coding-system pgg-messages-coding-system
+  "Coding system used when reading from a GnuPG external process.")
+
 (defvar pgg-scheme-gpg-instance nil)
 
 ;;;###autoload
@@ -56,8 +60,9 @@
            (luna-make-entity 'pgg-scheme-gpg))))
 
 (defun pgg-gpg-process-region (start end passphrase program args)
-  (let* ((output-file-name
-         (concat temporary-file-directory (make-temp-name "pgg-output")))
+  (let* ((output-file-name (make-temp-name
+                           (expand-file-name "pgg-output"
+                                             temporary-file-directory)))
         (args
          `("--status-fd" "2"
            ,@(if passphrase '("--passphrase-fd" "0"))
     (unwind-protect
        (progn
          (set-default-file-modes 448)
-         (let ((coding-system-for-write 'binary))
-           (setq process
-                 (apply #'start-process "*GnuPG*" errors-buffer
-                        program args)))
+         (setq process
+               (apply #'binary-to-text-funcall
+                      pgg-gpg-messages-coding-system
+                      #'start-process "*GnuPG*" errors-buffer
+                      program args))
          (set-process-sentinel process #'ignore)
          (when passphrase
            (process-send-string process (concat passphrase "\n")))
   (let ((args '("--batch" "--verify")))
     (when (stringp signature)
       (setq args (append args (list signature))))
+    (setq args (append args '("-")))
     (pgg-gpg-process-region start end nil pgg-gpg-program args)
     (with-current-buffer pgg-errors-buffer
       (goto-char (point-min))