Sync up with EMIKO 1.13.9.
authorueno <ueno>
Mon, 31 Jan 2000 17:09:40 +0000 (17:09 +0000)
committerueno <ueno>
Mon, 31 Jan 2000 17:09:40 +0000 (17:09 +0000)
ChangeLog
mime-image.el
mime-pgp.el
pgg-gpg.el
pgg-pgp.el
pgg-pgp5.el
pgg.el
semi-setup.el

index 1c06a6f..b1cbbbf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2000-01-24   Daiki Ueno  <ueno@ueda.info.waseda.ac.jp>
+
+       * mime-image.el [Emacs21]: Require `image' when compiling.
+       (image-normalize): Use `create-image' with 3rd arg `data-p'.
+        (create-image): Advice it to accept 3rd arg `data-p'.
+
+       * pgg-pgp.el. pgg-pgp5.el
+       (pgg-scheme-verify-region): Don't send buffer contents.
+
+       * mime-pgp.el (mime-view-application/pkcs7-mime): Rename from
+       `mime-decrypt-application/pkcs7-mime'; handle `smime-type'
+       parameter; abolish local variable `representation-type'.
+
+       * semi-setup.el: Rename `mime-decrypt-application/pkcs7-mime' to
+       `mime-view-application/pkcs7-mime'.
+
+2000-01-18   Daiki Ueno  <ueno@ueda.info.waseda.ac.jp>
+
+       * pgg.el,pgp-gpg.el,pgg-pgp.el,pgg-pgp5.el
+       (pgg-scheme-lookup-key-string,pgg-scheme-encrypt-region,
+       pgg-scheme-decrypt-region,pgg-scheme-sign-region,
+       pgg-scheme-verify-region,pgg-scheme-insert-key,
+       pgg-scheme-snarf-keys-region): Prepend `pgg-scheme' to each symbol.
+
+       * pgg.el
+       (pgg-encrypt-region,pgg-decrypt-region,pgg-sign-region,
+       pgg-verify-region,pgg-insert-key,pgg-snarf-keys-region,
+       pgg-lookup-key-string): Don't use `luna-send'.
+
 2000-01-17  MORIOKA Tomohiko  <tomo@m17n.org>
 
        * mime-view.el (mime-view-entity-button-visible-p): Comment out.
        (postpet-decode): Likewise.
        (mime-display-application/x-postpet): Likewise.
 
+2000-01-11  Nakagawa, Makoto  <Makoto.Nakagawa@jp.compaq.com>
+
+       * pgg-pgp.el, pgg-pgp5.el
+       (pgg-scheme-lookup-key-string): Fix number of arguments against
+       call-process.
+
+       * pgg-pgp5.el (pgg-scheme-verify-region): Analize process output
+       to see whether verify successed or not.
+
 2000-01-05  Katsumi Yamaoka   <yamaoka@jpl.org>
 
        * Makefile, README.en: Update for the new CVS server.
index bdfe1d8..341ee25 100644 (file)
     (or (memq format image-native-formats)
        (find-if (function
                  (lambda (native)
-                   (image-converter-chain format native)
-                   ))
-                image-native-formats)
-       ))
+                   (image-converter-chain format native)))
+                image-native-formats)))
 
   (image-register-netpbm-utilities)
   (image-register-converter 'pic 'ppm "pictoppm")
   (defsubst-maybe image-invalid-glyph-p (glyph)
     (or (null (aref glyph 0))
        (null (aref glyph 2))
-       (equal (aref glyph 2) "")
-       ))
-  )
+       (equal (aref glyph 2) ""))))
  ((featurep 'mule)
 
+  (eval-when-compile (ignore-errors (require 'image)))
+
   (eval-and-compile
-    (autoload 'bitmap-insert-xbm-buffer "bitmap")
-    )
+    (autoload 'bitmap-insert-xbm-buffer "bitmap"))
 
   (static-if (fboundp 'image-type-available-p)
       (defalias-maybe 'image-inline-p 'image-type-available-p)
     (defun-maybe image-inline-p (format)
       (memq format image-native-formats)))
 
+  (static-unless (or (not (fboundp 'create-image))
+                    (memq 'data-p (aref (symbol-function 'create-image) 0)))
+    (defadvice create-image
+      (around data-p (file-or-data &optional type data-p &rest props) activate)
+      (if (ad-get-arg 2)
+         (setq ad-return-value
+               (nconc 
+                (list 'image ':type (ad-get-arg 1) ':data (ad-get-arg 0))
+                props))
+       (ad-set-args 0 (list (ad-get-arg 0) (ad-get-arg 1) (ad-get-arg 3)))
+       ad-do-it)))
+
   (defun-maybe image-normalize (format data)
     (if (memq format '(xbm xpm))
-       (list 'image ':type format ':data data)
+       (create-image data format 'data)
       (let ((image-file
             (make-temp-name
              (expand-file-name "tm" temporary-file-directory))))
        (with-temp-buffer
          (insert data)
          (write-region-as-binary (point-min)(point-max) image-file))
-       (list 'image ':type format ':file image-file)
-       )))
+       (create-image image-file format))))
 
   (defun image-insert-at-point (image)
     (static-if (fboundp 'insert-image)
                (sit-for 0)))
          (let ((file (plist-get (cdr image) ':file)))
            (and file (file-exists-p file)
-                (delete-file file)
-                )))
+                (delete-file file))))
       (when (eq (plist-get (cdr image) ':type) 'xbm)
        (save-restriction
          (narrow-to-region (point)(point))
          (insert (plist-get (cdr image) ':data))
          (let ((mark (set-marker (make-marker) (point))))
            (bitmap-insert-xbm-buffer (current-buffer))
-           (delete-region (point-min) mark))
-         ))))
+           (delete-region (point-min) mark))))))
 
   (defsubst-maybe image-invalid-glyph-p (glyph)
-    (not (eq 'image (nth 0 glyph))))
-  ))
+    (not (eq 'image (nth 0 glyph))))))
 
 ;;
 ;; X-Face
     (autoload 'highlight-headers "highlight-headers"))
 
   (defun mime-preview-x-face-function-use-highlight-headers ()
-    (highlight-headers (point-min) (re-search-forward "^$" nil t) t)
-    )
+    (highlight-headers (point-min) (re-search-forward "^$" nil t) t))
   (add-hook 'mime-display-header-hook
-           'mime-preview-x-face-function-use-highlight-headers)
-  )
+           'mime-preview-x-face-function-use-highlight-headers))
  ((featurep 'mule)
   (require 'x-face-mule)
   (when (exec-installed-p uncompface-program exec-path)
     (add-hook 'mime-display-header-hook
-             'x-face-decode-message-header))
-  ))
+             'x-face-decode-message-header))))
 
 (defvar mime-image-format-alist
   '((image jpeg                jpeg)
        (list (cons 'type type)(cons 'subtype subtype)
             '(body . visible)
             (cons 'body-presentation-method #'mime-display-image)
-            (cons 'image-format format))
-       ))))
+            (cons 'image-format format))))))
 
 
 ;;; @ content filter for images
                  (` (vector 'xbm :data
                             (list width height (read cur))))
                '(` (image :type xbm :width (, width) :height (, height)
-                          :data (, (read cur))))))))))
-  )
+                          :data (, (read cur)))))))))))
 
 (defun mime-display-image (entity situation)
   (message "Decoding image...")
index 6ddaec9..7012859 100644 (file)
            (point-max))
           (goto-char (point-min))
           (while (re-search-forward "^- -" nil t)
-            (replace-match "-")
-            )
+            (replace-match "-"))
           (setq representation-type (if (mime-entity-cooked-p entity)
-                                        'cooked))
-          )
+                                        'cooked)))
          ((progn
             (goto-char (point-min))
             (re-search-forward "^-+BEGIN PGP MESSAGE-+$" nil t))
           (pgg-decrypt-region (point-min)(point-max))
           (delete-region (point-min)(point-max))
           (insert-buffer pgg-output-buffer)
-          (setq representation-type 'binary)
-          ))
+          (setq representation-type 'binary)))
     (setq major-mode 'mime-show-message-mode)
     (save-window-excursion (mime-view-buffer nil preview-buffer mother
                                             nil representation-type))
-    (set-window-buffer p-win preview-buffer)
-    ))
+    (set-window-buffer p-win preview-buffer)))
 
 
 ;;; @ Internal method for application/pgp-signature
       (set-buffer mime-echo-buffer-name)
       (set-window-start 
        (get-buffer-window mime-echo-buffer-name)
-       (point-max))
-      )
+       (point-max)))
     (mime-write-entity-content entity sig-file)
     (unwind-protect
        (with-temp-buffer
            (set-buffer mime-echo-buffer-name)
            (insert-buffer-substring (if status pgg-output-buffer
                                       pgg-errors-buffer))))
-      (delete-file sig-file))
-    ))
+      (delete-file sig-file))))
 
 
 ;;; @ Internal method for application/pgp-encrypted
                   (1- knum)
                 (1+ knum)))
         (orig-entity (nth onum (mime-entity-children mother))))
-    (mime-view-application/pgp orig-entity situation)
-    ))
+    (mime-view-application/pgp orig-entity situation)))
 
 
 ;;; @ Internal method for application/pgp-keys
     (set-buffer mime-echo-buffer-name)
     (set-window-start 
      (get-buffer-window mime-echo-buffer-name)
-     (point-max))
-    )
+     (point-max)))
   (with-temp-buffer
     (mime-insert-entity-content entity)
     (mime-decode-region (point-min) (point-max)
       (save-excursion 
        (set-buffer mime-echo-buffer-name)
        (insert-buffer-substring (if status pgg-output-buffer
-                                  pgg-errors-buffer)))
-      )))
+                                  pgg-errors-buffer))))))
 
 
 ;;; @ Internal method for application/pkcs7-signature
       (set-buffer mime-echo-buffer-name)
       (set-window-start 
        (get-buffer-window mime-echo-buffer-name)
-       (point-max))
-      )
+       (point-max)))
     (mime-write-entity entity sig-file)
     (unwind-protect
        (with-temp-buffer
            (set-buffer mime-echo-buffer-name)
            (insert-buffer-substring (if status smime-output-buffer
                                       smime-errors-buffer))))
-      (delete-file sig-file))
-    ))
+      (delete-file sig-file))))
 
 
 ;;; @ Internal method for application/pkcs7-mime
 ;;;
 ;;; It is based on RFC 2633 (S/MIME version 3).
 
-(defun mime-decrypt-application/pkcs7-mime (entity situation)
+(defun mime-view-application/pkcs7-mime (entity situation)
   (let* ((p-win (or (get-buffer-window (current-buffer))
                    (get-largest-window)))
         (new-name
          (format "%s-%s" (buffer-name) (mime-entity-number entity)))
         (mother (current-buffer))
-        (preview-buffer (concat "*Preview-" (buffer-name) "*"))
-        representation-type)
-    (set-buffer (get-buffer-create new-name))
-    (let ((inhibit-read-only t)
-         buffer-read-only)
-      (erase-buffer)
-      (mime-insert-entity entity)
-      (smime-decrypt-region (point-min)(point-max))
-      (delete-region (point-min)(point-max))
-      (insert-buffer smime-output-buffer))
-    (setq major-mode 'mime-show-message-mode)
-    (save-window-excursion (mime-view-buffer nil preview-buffer mother
-                                            nil 'binary))
-    (set-window-buffer p-win preview-buffer)
-    ))
+        (preview-buffer (concat "*Preview-" (buffer-name) "*")))
+    (when (memq (or (cdr (assq 'smime-type situation)) enveloped-data)
+               '(enveloped-data signed-data))
+      (set-buffer (get-buffer-create new-name))
+      (let ((inhibit-read-only t)
+           buffer-read-only)
+       (erase-buffer)
+       (mime-insert-entity entity)
+       (smime-decrypt-region (point-min)(point-max))
+       (delete-region (point-min)(point-max))
+       (insert-buffer smime-output-buffer))
+      (setq major-mode 'mime-show-message-mode)
+      (save-window-excursion (mime-view-buffer nil preview-buffer mother
+                                              nil 'binary))
+      (set-window-buffer p-win preview-buffer))))
 
 
 ;;; @ end
index e6528b6..676335e 100644 (file)
@@ -1,6 +1,6 @@
 ;;; pgg-gpg.el --- GnuPG support for PGG.
 
-;; Copyright (C) 1999 Daiki Ueno
+;; Copyright (C) 1999,2000 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@ueda.info.waseda.ac.jp>
 ;; Created: 1999/10/28
@@ -53,9 +53,8 @@
   :type 'string)
 
 (eval-and-compile
-  (luna-define-class pgg-scheme-gpg (pgg-scheme))
-  )
-  
+  (luna-define-class pgg-scheme-gpg (pgg-scheme)))
+
 (defvar pgg-gpg-user-id nil
   "GnuPG ID of your default identity.")
 
@@ -96,7 +95,7 @@
      (setq process
           (apply #'start-process-shell-command "*GnuPG*" output-buffer
                  program args)))
-    (set-process-sentinel process 'ignore)
+    (set-process-sentinel process #'ignore)
     (when passphrase
       (process-send-string process (concat passphrase "\n")))
     (process-send-region process start end)
       (delete-file status-file-name)
 
       (if (and process (eq 'run (process-status process)))
-         (interrupt-process process))
-      )
-    ))
+         (interrupt-process process)))))
 
-(luna-define-method lookup-key-string ((scheme pgg-scheme-gpg)
-                                      string &optional type)
+(luna-define-method pgg-scheme-lookup-key-string ((scheme pgg-scheme-gpg)
+                                                 string &optional type)
   (let ((args (list "--with-colons" "--no-greeting" "--batch" 
                    (if type "--list-secret-keys" "--list-keys")
                    string)))
-    (pgg-gpg-process-region (point)(point) nil pgg-gpg-program args)
     (with-current-buffer pgg-output-buffer
+      (buffer-disable-undo)
+      (erase-buffer)
+      (apply #'call-process pgg-gpg-program nil t nil args)
       (goto-char (point-min))
       (when (re-search-forward "^\\(sec\\|pub\\):"  nil t)
        (substring 
                 (buffer-substring (match-end 0)
                                   (progn (end-of-line)(point)))
                 ":"))
-        8)))
-    ))
+        8)))))
 
-(luna-define-method encrypt-region ((scheme pgg-scheme-gpg) 
-                                   start end recipients)
+(luna-define-method pgg-scheme-encrypt-region ((scheme pgg-scheme-gpg) 
+                                              start end recipients)
   (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
         (args 
          `("--batch" "--armor" "--always-trust" "--encrypt"
                                         (concat "\"" rcpt "\""))) 
                                 (append recipients
                                         (if pgg-encrypt-for-me
-                                            (list pgg-gpg-user-id)))))))
-         ))
+                                            (list pgg-gpg-user-id)))))))))
     (pgg-as-lbt start end 'CRLF
-      (pgg-gpg-process-region start end nil pgg-gpg-program args)
-      )
+      (pgg-gpg-process-region start end nil pgg-gpg-program args))
     (pgg-process-when-success
-      (pgg-convert-lbt-region (point-min)(point-max) 'LF))
-    ))
+      (pgg-convert-lbt-region (point-min)(point-max) 'LF))))
 
-(luna-define-method decrypt-region ((scheme pgg-scheme-gpg) 
-                                   start end)
+(luna-define-method pgg-scheme-decrypt-region ((scheme pgg-scheme-gpg) 
+                                              start end)
   (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
         (passphrase
          (pgg-read-passphrase 
                      scheme pgg-gpg-user-id 'encrypt)))
         (args '("--batch" "--decrypt")))
     (pgg-gpg-process-region start end passphrase pgg-gpg-program args)
-    (pgg-process-when-success nil)
-    ))
+    (pgg-process-when-success nil)))
 
-(luna-define-method sign-region ((scheme pgg-scheme-gpg) 
-                                start end &optional cleartext)
+(luna-define-method pgg-scheme-sign-region ((scheme pgg-scheme-gpg) 
+                                           start end &optional cleartext)
   (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
         (passphrase
          (pgg-read-passphrase 
         (inhibit-read-only t)
         buffer-read-only)
     (pgg-as-lbt start end 'CRLF
-      (pgg-gpg-process-region start end passphrase pgg-gpg-program args)
-      )
+      (pgg-gpg-process-region start end passphrase pgg-gpg-program args))
     (pgg-process-when-success
       (pgg-convert-lbt-region (point-min)(point-max) 'LF)
       (when (re-search-forward "^-+BEGIN PGP SIGNATURE" nil t);XXX
          (if pgg-cache-passphrase
              (pgg-add-passphrase-cache 
               (cdr (assq 'key-identifier packet))
-              passphrase)))))
-    ))
+              passphrase)))))))
 
-(luna-define-method verify-region ((scheme pgg-scheme-gpg) 
-                                  start end &optional signature)
+(luna-define-method pgg-scheme-verify-region ((scheme pgg-scheme-gpg) 
+                                             start end &optional signature)
   (let ((args '("--batch" "--verify")))
     (when (stringp signature)
       (setq args (append args (list signature))))
            (set-buffer pgg-output-buffer)
            (insert-buffer-substring pgg-errors-buffer)
            t)
-       nil))
-    ))
+       nil))))
 
-(luna-define-method insert-key ((scheme pgg-scheme-gpg))
+(luna-define-method pgg-scheme-insert-key ((scheme pgg-scheme-gpg))
   (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id))
         (args (list "--batch" "--export" "--armor" 
                     (concat "\"" pgg-gpg-user-id "\""))))
     (pgg-gpg-process-region (point)(point) nil pgg-gpg-program args)
-    (insert-buffer-substring pgg-output-buffer)
-    ))
+    (insert-buffer-substring pgg-output-buffer)))
 
-(luna-define-method snarf-keys-region ((scheme pgg-scheme-gpg)
-                                      start end)
+(luna-define-method pgg-scheme-snarf-keys-region ((scheme pgg-scheme-gpg)
+                                                 start end)
   (let ((args '("--import" "--batch" "-")) status)
     (pgg-gpg-process-region start end nil pgg-gpg-program args)
     (set-buffer pgg-status-buffer)
                "\tSecret keys are imported.\n")))
     (append-to-buffer pgg-output-buffer
                      (point-min)(point-max))
-    (pgg-process-when-success nil)
-    ))
+    (pgg-process-when-success nil)))
 
 (provide 'pgg-gpg)
 
index 9193660..083097f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; pgg-pgp.el --- PGP 2.* and 6.* support for PGG.
 
-;; Copyright (C) 1999 Daiki Ueno
+;; Copyright (C) 1999,2000 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@ueda.info.waseda.ac.jp>
 ;; Created: 1999/11/02
@@ -53,9 +53,8 @@
   :type 'string)
 
 (eval-and-compile
-  (luna-define-class pgg-scheme-pgp (pgg-scheme))
-  )
-  
+  (luna-define-class pgg-scheme-pgp (pgg-scheme)))
+
 (defvar pgg-pgp-user-id nil
   "GnuPG ID of your default identity.")
 
@@ -90,7 +89,7 @@
      (setq process
           (apply #'start-process-shell-command "*PGP*" output-buffer
                  program args)))
-    (set-process-sentinel process 'ignore)
+    (set-process-sentinel process #'ignore)
     (when passphrase
       (process-send-string process (concat passphrase "\n")))
     (process-send-region process start end)
       (delete-file errors-file-name)
       
       (if (and process (eq 'run (process-status process)))
-         (interrupt-process process))
-      )
-    ))
+         (interrupt-process process)))))
 
-(luna-define-method lookup-key-string ((scheme pgg-scheme-pgp) 
-                                      string &optional type)
+(luna-define-method pgg-scheme-lookup-key-string ((scheme pgg-scheme-pgp) 
+                                                 string &optional type)
   (let ((args (list "+batchmode" "+language=en" "-kv" string)))
     (with-current-buffer (get-buffer-create pgg-output-buffer)
       (buffer-disable-undo)
       (erase-buffer)
-      (apply #'call-process pgg-pgp-program nil t args)
+      (apply #'call-process pgg-pgp-program nil t nil args)
       (goto-char (point-min))
       (cond
        ((re-search-forward "^pub\\s +[0-9]+/" nil t);PGP 2.*
        (beginning-of-line 2)
        (substring 
         (nth 2 (split-string 
-                (buffer-substring (point)
-                                  (progn (end-of-line) (point)))
-                ))
-        2))))
-    ))
+                (buffer-substring (point)(progn (end-of-line) (point)))))
+        2))))))
 
-(luna-define-method encrypt-region ((scheme pgg-scheme-pgp) 
-                                   start end recipients)
+(luna-define-method pgg-scheme-encrypt-region ((scheme pgg-scheme-pgp) 
+                                              start end recipients)
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
         (args 
          `("+encrypttoself=off +verbose=1" "+batchmode"
                  (mapcar (lambda (rcpt) (concat "\"" rcpt "\""))
                          (append recipients
                                  (if pgg-encrypt-for-me
-                                     (list pgg-pgp-user-id))))))
-         ))
-    (pgg-pgp-process-region start end nil
-                           pgg-pgp-program args)
-    (pgg-process-when-success nil)
-    ))
+                                     (list pgg-pgp-user-id))))))))
+    (pgg-pgp-process-region start end nil pgg-pgp-program args)
+    (pgg-process-when-success nil)))
 
-(luna-define-method decrypt-region ((scheme pgg-scheme-pgp) 
-                                   start end)
+(luna-define-method pgg-scheme-decrypt-region ((scheme pgg-scheme-pgp) 
+                                              start end)
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
         (passphrase
          (pgg-read-passphrase 
                      scheme pgg-pgp-user-id 'encrypt)))
         (args 
          '("+verbose=1" "+batchmode" "+language=us" "-f")))
-    (pgg-pgp-process-region start end passphrase 
-                           pgg-pgp-program args)
-    (pgg-process-when-success nil)
-    ))
+    (pgg-pgp-process-region start end passphrase pgg-pgp-program args)
+    (pgg-process-when-success nil)))
 
-(luna-define-method sign-region ((scheme pgg-scheme-pgp) 
-                                start end &optional clearsign)
+(luna-define-method pgg-scheme-sign-region ((scheme pgg-scheme-pgp) 
+                                           start end &optional clearsign)
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
         (passphrase
          (pgg-read-passphrase 
          (list (if clearsign "-fast" "-fbast")
                "+verbose=1" "+language=us" "+batchmode"
                "-u" pgg-pgp-user-id)))
-    (pgg-pgp-process-region start end passphrase 
-                           pgg-pgp-program args)
+    (pgg-pgp-process-region start end passphrase pgg-pgp-program args)
     (pgg-process-when-success
       (goto-char (point-min))
       (when (re-search-forward "^-+BEGIN PGP" nil t);XXX
          (if pgg-cache-passphrase
              (pgg-add-passphrase-cache 
               (cdr (assq 'key-identifier packet))
-              passphrase)))))
-    ))
+              passphrase)))))))
 
-(luna-define-method verify-region ((scheme pgg-scheme-pgp) 
-                                  start end &optional signature)
+(luna-define-method pgg-scheme-verify-region ((scheme pgg-scheme-pgp) 
+                                             start end &optional signature)
   (let* ((basename (expand-file-name "pgg" temporary-file-directory))
         (orig-file (make-temp-name basename))
         (args '("+verbose=1" "+batchmode" "+language=us"))
     (unwind-protect
        (progn
          (set-default-file-modes 448)
-         (write-region-as-binary start end orig-file)
-         )
+         (write-region-as-binary start end orig-file))
       (set-default-file-modes orig-mode))
     (when (stringp signature)
       (copy-file signature (setq signature (concat orig-file ".asc")))
-      (setq args (append args (list signature orig-file)))
-      )
-    (pgg-pgp-process-region (point-min)(point-max) nil
-                           pgg-pgp-program args)
+      (setq args (append args (list signature orig-file))))
+    (pgg-pgp-process-region (point)(point) nil pgg-pgp-program args)
     (delete-file orig-file)
     (if signature (delete-file signature))
     (pgg-process-when-success
       (when (re-search-forward "^\\.$" nil t)
        (delete-region (point-min) 
                       (progn (beginning-of-line 2)
-                             (point)))))
-    ))
+                             (point)))))))
 
-(luna-define-method insert-key ((scheme pgg-scheme-pgp))
+(luna-define-method pgg-scheme-insert-key ((scheme pgg-scheme-pgp))
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
         (args
          (list "+verbose=1" "+batchmode" "+language=us" "-kxaf" 
                (concat "\"" pgg-pgp-user-id "\""))))
-    (pgg-pgp-process-region (point)(point) nil
-                            pgg-pgp-program args)
-    (insert-buffer-substring pgg-output-buffer)
-    ))
+    (pgg-pgp-process-region (point)(point) nil pgg-pgp-program args)
+    (insert-buffer-substring pgg-output-buffer)))
 
-(luna-define-method snarf-keys-region ((scheme pgg-scheme-pgp)
-                                      start end)
+(luna-define-method pgg-scheme-snarf-keys-region ((scheme pgg-scheme-pgp)
+                                                 start end)
   (let* ((pgg-pgp-user-id (or pgg-pgp-user-id pgg-default-user-id))
         (basename (expand-file-name "pgg" temporary-file-directory))
         (key-file (make-temp-name basename))
          (list "+verbose=1" "+batchmode" "+language=us" "-kaf" 
                key-file)))
     (write-region-as-raw-text-CRLF start end key-file)
-    (pgg-pgp-process-region start end nil
-                           pgg-pgp-program args)
+    (pgg-pgp-process-region start end nil pgg-pgp-program args)
     (delete-file key-file)
-    (pgg-process-when-success nil)
-    ))
+    (pgg-process-when-success nil)))
 
 (provide 'pgg-pgp)
 
index e8066fb..8ad30a2 100644 (file)
@@ -1,6 +1,6 @@
 ;;; pgg-pgp5.el --- PGP 5.* support for PGG.
 
-;; Copyright (C) 1999 Daiki Ueno
+;; Copyright (C) 1999,2000 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@ueda.info.waseda.ac.jp>
 ;; Created: 1999/11/02
@@ -68,9 +68,8 @@
   :type 'string)
 
 (eval-and-compile
-  (luna-define-class pgg-scheme-pgp5 (pgg-scheme))
-  )
-  
+  (luna-define-class pgg-scheme-pgp5 (pgg-scheme)))
+
 (defvar pgg-pgp5-user-id nil
   "GnuPG ID of your default identity.")
 
      (setq process
           (apply #'start-process-shell-command "*PGP*" output-buffer
                  program args)))
-    (set-process-sentinel process 'ignore)
+    (set-process-sentinel process #'ignore)
     (when passphrase
       (process-send-string process (concat passphrase "\n")))
     (process-send-region process start end)
       (delete-file errors-file-name)
       
       (if (and process (eq 'run (process-status process)))
-         (interrupt-process process))
-      )
-    ))
+         (interrupt-process process)))))
 
-(luna-define-method lookup-key-string ((scheme pgg-scheme-pgp5) 
-                                      string &optional type)
+(luna-define-method pgg-scheme-lookup-key-string ((scheme pgg-scheme-pgp5) 
+                                                 string &optional type)
   (let ((args (list "+language=en" "-l" string)))
     (with-current-buffer (get-buffer-create pgg-output-buffer)
       (buffer-disable-undo)
       (erase-buffer)
-      (apply #'call-process pgg-pgp5-pgpk-program  nil t args)
+      (apply #'call-process pgg-pgp5-pgpk-program nil t nil args)
       (goto-char (point-min))
       (when (re-search-forward "^sec" nil t)
        (substring 
         (nth 2 (split-string 
-                (buffer-substring (match-end 0)
-                                  (progn (end-of-line)(point)))
-                ))
-        2)))
-    ))
-
-(luna-define-method encrypt-region ((scheme pgg-scheme-pgp5) 
-                                   start end recipients)
+                (buffer-substring (match-end 0)(progn (end-of-line)(point)))))
+        2)))))
+
+(luna-define-method pgg-scheme-encrypt-region ((scheme pgg-scheme-pgp5) 
+                                              start end recipients)
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
         (args 
          `("+NoBatchInvalidKeys=off" "-fat" "+batchmode=1"
                                         (concat "\"" rcpt "\""))) 
                                 (append recipients
                                         (if pgg-encrypt-for-me
-                                            (list pgg-pgp5-user-id)))))))
-         ))
-    (pgg-pgp5-process-region start end nil
-                            pgg-pgp5-pgpe-program args)
-    (pgg-process-when-success nil)
-    ))
-
-(luna-define-method decrypt-region ((scheme pgg-scheme-pgp5) 
-                                   start end)
+                                            (list pgg-pgp5-user-id)))))))))
+    (pgg-pgp5-process-region start end nil pgg-pgp5-pgpe-program args)
+    (pgg-process-when-success nil)))
+
+(luna-define-method pgg-scheme-decrypt-region ((scheme pgg-scheme-pgp5) 
+                                              start end)
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
         (passphrase
          (pgg-read-passphrase 
                      scheme pgg-pgp5-user-id 'encrypt)))
         (args 
          '("+verbose=1" "+batchmode=1" "+language=us" "-f")))
-    (pgg-pgp5-process-region start end passphrase 
-                            pgg-pgp5-pgpv-program args)
-    (pgg-process-when-success nil)
-    ))
+    (pgg-pgp5-process-region start end passphrase pgg-pgp5-pgpv-program args)
+    (pgg-process-when-success nil)))
 
-(luna-define-method sign-region ((scheme pgg-scheme-pgp5) 
-                                start end &optional clearsign)
+(luna-define-method pgg-scheme-sign-region ((scheme pgg-scheme-pgp5) 
+                                           start end &optional clearsign)
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
         (passphrase
          (pgg-read-passphrase 
          (list (if clearsign "-fat" "-fbat")
                "+verbose=1" "+language=us" "+batchmode=1"
                "-u" pgg-pgp5-user-id)))
-    (pgg-pgp5-process-region start end passphrase 
-                            pgg-pgp5-pgps-program args)
+    (pgg-pgp5-process-region start end passphrase pgg-pgp5-pgps-program args)
     (pgg-process-when-success
       (when (re-search-forward "^-+BEGIN PGP SIGNATURE" nil t);XXX
        (let ((packet 
          (if pgg-cache-passphrase
              (pgg-add-passphrase-cache 
               (cdr (assq 'key-identifier packet))
-              passphrase)))))
-    ))
+              passphrase)))))))
 
-(luna-define-method verify-region ((scheme pgg-scheme-pgp5) 
-                                  start end &optional signature)
+(luna-define-method pgg-scheme-verify-region ((scheme pgg-scheme-pgp5) 
+                                             start end &optional signature)
   (let* ((basename (expand-file-name "pgg" temporary-file-directory))
         (orig-file (make-temp-name basename))
         (args '("+verbose=1" "+batchmode=1" "+language=us"))
     (unwind-protect
        (progn
          (set-default-file-modes 448)
-         (write-region-as-binary start end orig-file)
-         )
+         (write-region-as-binary start end orig-file))
       (set-default-file-modes orig-mode))
     (when (stringp signature)
       (copy-file signature (setq signature (concat orig-file ".asc")))
-      (setq args (append args (list signature)))
-      )
-    (pgg-pgp5-process-region (point-min)(point-max) nil
-                            pgg-pgp5-pgpv-program args)
+      (setq args (append args (list signature))))
+    (pgg-pgp5-process-region (point)(point) nil pgg-pgp5-pgpv-program args)
     (delete-file orig-file)
     (if signature (delete-file signature))
-    (pgg-process-when-success nil)
-    ))
+    (with-current-buffer pgg-errors-buffer
+      (goto-char (point-min))
+      (re-search-forward "^Good signature" nil t))))
 
-(luna-define-method insert-key ((scheme pgg-scheme-pgp5))
+(luna-define-method pgg-scheme-insert-key ((scheme pgg-scheme-pgp5))
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
         (args
          (list "+verbose=1" "+batchmode=1" "+language=us" "-x" 
                (concat "\"" pgg-pgp5-user-id "\""))))
-    (pgg-pgp5-process-region (point)(point) nil
-                            pgg-pgp5-pgpk-program args)
-    (insert-buffer-substring pgg-output-buffer)
-    ))
+    (pgg-pgp5-process-region (point)(point) nil pgg-pgp5-pgpk-program args)
+    (insert-buffer-substring pgg-output-buffer)))
 
-(luna-define-method snarf-keys-region ((scheme pgg-scheme-pgp5)
-                                      start end)
+(luna-define-method pgg-scheme-snarf-keys-region ((scheme pgg-scheme-pgp5)
+                                                 start end)
   (let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
         (basename (expand-file-name "pgg" temporary-file-directory))
         (key-file (make-temp-name basename))
          (list "+verbose=1" "+batchmode=1" "+language=us" "-a" 
                key-file)))
     (write-region-as-raw-text-CRLF start end key-file)
-    (pgg-pgp5-process-region start end nil
-                            pgg-pgp5-pgpk-program args)
+    (pgg-pgp5-process-region start end nil pgg-pgp5-pgpk-program args)
     (delete-file key-file)
-    (pgg-process-when-success nil)
-    ))
+    (pgg-process-when-success nil)))
 
 (provide 'pgg-pgp5)
 
diff --git a/pgg.el b/pgg.el
index fd6eaea..4557a6d 100644 (file)
--- a/pgg.el
+++ b/pgg.el
@@ -1,6 +1,6 @@
 ;;; pgg.el --- glue for the various PGP implementations.
 
-;; Copyright (C) 1999 Daiki Ueno
+;; Copyright (C) 1999,2000 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@ueda.info.waseda.ac.jp>
 ;; Created: 1999/10/28
@@ -47,8 +47,7 @@
   (calist field-type field-value)
   (let ((s-field (assq field-type calist)))
     (cond ((null s-field)
-          (cons (cons field-type field-value) calist)
-          )
+          (cons (cons field-type field-value) calist))
          ((memq (cdr s-field) field-value)
           calist))))
 
 (eval-and-compile
   (luna-define-class pgg-scheme ())
 
-  (luna-define-internal-accessors 'pgg-scheme)
-  )
+  (luna-define-internal-accessors 'pgg-scheme))
 
-(luna-define-generic lookup-key-string (scheme string &optional type)
+(luna-define-generic pgg-scheme-lookup-key-string
+  (scheme string &optional type)
   "Search keys associated with STRING")
 
-(luna-define-generic encrypt-region (scheme start end recipients)
+(luna-define-generic pgg-scheme-encrypt-region (scheme start end recipients)
   "Encrypt the current region between START and END.")
 
-(luna-define-generic decrypt-region (scheme start end)
+(luna-define-generic pgg-scheme-decrypt-region (scheme start end)
   "Decrypt the current region between START and END.")
 
-(luna-define-generic sign-region (scheme start end &optional cleartext)
+(luna-define-generic pgg-scheme-sign-region
+  (scheme start end &optional cleartext)
   "Make detached signature from text between START and END.")
 
-(luna-define-generic verify-region (scheme start end &optional signature)
+(luna-define-generic pgg-scheme-verify-region
+  (scheme start end &optional signature)
   "Verify region between START and END
 as the detached signature SIGNATURE.")
 
-(luna-define-generic insert-key (scheme)
+(luna-define-generic pgg-scheme-insert-key (scheme)
   "Insert public key at point.")
 
-(luna-define-generic snarf-keys-region (scheme start end)
+(luna-define-generic pgg-scheme-snarf-keys-region (scheme start end)
   "Add all public keys in region between START
 and END to the keyring.")
 
@@ -161,8 +162,7 @@ and END to the keyring.")
                                   buffer-file-coding-system)
             (prog1 (save-excursion ,@body)
               (push nil buffer-undo-list)
-              (ignore-errors (undo)))
-            )))
+              (ignore-errors (undo))))))
      (save-restriction
        (narrow-to-region ,start ,end)
        ,@body)))
@@ -180,14 +180,12 @@ and END to the keyring.")
       (progn
        (delete-region start end)
        (insert-buffer-substring pgg-output-buffer)
-       (decode-coding-region start (point) buffer-file-coding-system)
-       )
+       (decode-coding-region start (point) buffer-file-coding-system))
     (let ((temp-buffer-show-function 
           (function pgg-temp-buffer-show-function)))
       (with-output-to-temp-buffer pgg-echo-buffer
        (set-buffer standard-output)
-       (insert-buffer-substring pgg-errors-buffer)))
-    ))
+       (insert-buffer-substring pgg-errors-buffer)))))
 
 (defvar pgg-passphrase-cache-expiry 16)
 (defvar pgg-passphrase-cache (make-vector 7 0))
@@ -232,8 +230,7 @@ and END to the keyring.")
          (forward-line 1)))
        (LF
        (while (re-search-forward "\r$" pgg-conversion-end t)
-         (replace-match ""))))
-     ))
+         (replace-match ""))))))
 
 (put 'pgg-as-lbt 'lisp-indent-function 3)
 
@@ -264,9 +261,9 @@ and END to the keyring.")
    (list (region-beginning)(region-end)
         (split-string (read-string "Recipients: ") "[ \t,]+")))
   (let* ((entity (pgg-make-scheme pgg-default-scheme))
-        (status (pgg-save-coding-system start end
-                  (luna-send entity 'encrypt-region entity
-                             (point-min)(point-max) rcpts))))
+        (status 
+         (pgg-save-coding-system start end
+           (pgg-scheme-encrypt-region entity (point-min)(point-max) rcpts))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -285,9 +282,9 @@ and END to the keyring.")
                                               packet))))
              pgg-default-scheme))
         (entity (pgg-make-scheme scheme))
-        (status (pgg-save-coding-system start end
-                  (luna-send entity 'decrypt-region entity 
-                             (point-min)(point-max)))))
+        (status
+         (pgg-save-coding-system start end
+           (pgg-scheme-decrypt-region entity (point-min)(point-max)))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -300,9 +297,8 @@ a detached signature."
   (interactive "r")
   (let* ((entity (pgg-make-scheme pgg-default-scheme))
         (status (pgg-save-coding-system start end
-                  (luna-send entity 'sign-region entity
-                             (point-min)(point-max)
-                             (or (interactive-p) cleartext)))))
+                  (pgg-scheme-sign-region entity (point-min)(point-max)
+                                          (or (interactive-p) cleartext)))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -322,8 +318,8 @@ signer's public key from `pgg-default-keyserver-address'."
              (buffer-disable-undo)
              (set-buffer-multibyte nil)
              (insert-file-contents signature)
-             (cdr (assq 2 (pgg-decode-armor-region (point-min)(point-max))))
-             )))
+             (cdr (assq 2 (pgg-decode-armor-region 
+                           (point-min)(point-max)))))))
         (scheme
          (or pgg-scheme
              (cdr (assq 'scheme
@@ -346,16 +342,15 @@ signer's public key from `pgg-default-keyserver-address'."
                   pgg-default-keyserver-address))
         (pgg-fetch-key keyserver key))
     (setq status (pgg-save-coding-system start end
-                  (luna-send entity 'verify-region entity 
-                             (point-min)(point-max) signature)))
+                  (pgg-scheme-verify-region entity (point-min)(point-max)
+                                            signature)))
     (when (interactive-p)
       (let ((temp-buffer-show-function
             (function pgg-temp-buffer-show-function)))
        (with-output-to-temp-buffer pgg-echo-buffer
          (set-buffer standard-output)
          (insert-buffer-substring (if status pgg-output-buffer
-                                    pgg-errors-buffer))
-         )))
+                                    pgg-errors-buffer)))))
     status))
 
 ;;;###autoload
@@ -363,7 +358,7 @@ signer's public key from `pgg-default-keyserver-address'."
   "Insert the ASCII armored public key."
   (interactive)
   (let ((entity (pgg-make-scheme (or pgg-scheme pgg-default-scheme))))
-    (luna-send entity 'insert-key entity)))
+    (pgg-scheme-insert-key entity)))
 
 ;;;###autoload
 (defun pgg-snarf-keys-region (start end)
@@ -371,11 +366,11 @@ signer's public key from `pgg-default-keyserver-address'."
   (interactive "r")
   (let ((entity (pgg-make-scheme (or pgg-scheme pgg-default-scheme))))
     (pgg-save-coding-system start end
-      (luna-send entity 'snarf-keys-region entity start end))))
+      (pgg-scheme-snarf-keys-region entity start end))))
 
 (defun pgg-lookup-key-string (string &optional type)
   (let ((entity (pgg-make-scheme (or pgg-scheme pgg-default-scheme))))
-    (luna-send entity 'lookup-key-string entity string type)))
+    (pgg-scheme-lookup-key-string entity string type)))
 
 (defvar pgg-insert-url-function  (function pgg-insert-url-with-w3))
 
@@ -402,8 +397,7 @@ signer's public key from `pgg-default-keyserver-address'."
        (delete-process process)
        (if (and process (eq 'run (process-status process)))
           (interrupt-process process))
-       (buffer-string)))
-    ))
+       (buffer-string)))))
 
 (defun pgg-fetch-key (keyserver key)
   "Attempt to fetch a KEY from KEYSERVER for addition to PGP or GnuPG keyring."
@@ -425,8 +419,7 @@ signer's public key from `pgg-default-keyserver-address'."
        (insert "\n")
        (with-temp-buffer
          (insert-buffer-substring pgg-output-buffer)
-         (pgg-snarf-keys-region (point-min)(point-max))))
-      )))
+         (pgg-snarf-keys-region (point-min)(point-max)))))))
 
 
 (provide 'pgg)
index 63751ea..57e4bda 100644 (file)
@@ -138,13 +138,13 @@ it is used as hook to set."
         (mime-add-condition
          'action
          '((type . application)(subtype . pkcs7-mime)
-           (method . mime-decrypt-application/pkcs7-mime))
+           (method . mime-view-application/pkcs7-mime))
          'strict "mime-pgp")
 
         (mime-add-condition
          'action
          '((type . application)(subtype . x-pkcs7-mime)
-           (method . mime-decrypt-application/pkcs7-mime))
+           (method . mime-view-application/pkcs7-mime))
          'strict "mime-pgp")
         ))
   )