1999-04-14 Katsumi Yamaoka <yamaoka@jpl.org>
+ * mime-ui-en.texi, mime-ui-ja.texi: Sync up with .sgml files.
+ * mime-ui-en.sgml, mime-ui-ja.sgml: Modify a description for
+ simplified `pgp-function-alist'.
+
+ * semi-def.el (pgp-function-alist): Simplify. Use
+ `mime-mc-encrypt-region', `mime-mc-traditional-sign-region',
+ `mime-mc-sign-region' and `mime-mc-fetch-key' for it.
+
+ * mime-mc.el (mime-mc-insert-public-key, mime-mc-snarf-keys,
+ mime-mc-decrypt, mime-mc-verify): Add doc strings.
+ (mime-mc-encrypt-region, mime-mc-traditional-sign-region,
+ mime-mc-sign-region, mime-mc-fetch-key): New functions.
+ (TopLevel): Add autoloads "mc-gpg", "mc-pgp5" and "mc-pgp" for the
+ functions `mc-gpg-fetch-key', `mc-gpg-sign-region',
+ `mc-pgp50-fetch-key', `mc-pgp50-sign-region', `mc-pgp-fetch-key'
+ and `mc-pgp-sign-region'.
+
+ * mime-pgp.el (mime-pgp-fetch-key): Kill useless buffers after
+ fetching.
+ (mime-pgp-show-fetched-key-for-pgp50, mime-pgp-show-fetched-key):
+ Show fetched key in the window of `mime-echo-buffer-name' if it is
+ alive, otherwise use `display-buffer'; minimize the window height;
+ return buffer object to be killed.
+
+1999-04-14 Katsumi Yamaoka <yamaoka@jpl.org>
+
* mime-pgp.el (mime-pgp-fetch-key,
mime-pgp-show-fetched-key-for-pgp,
mime-pgp-show-fetched-key-for-pgp50,
(function (lambda (elem) (apply 'autoload elem)))
'(
(mc-gpg-debug-print "mc-gpg")
+
(mc-gpg-encrypt-region "mc-gpg")
+ (mc-gpg-fetch-key "mc-gpg")
(mc-gpg-lookup-key "mc-gpg")
+ (mc-gpg-sign-region "mc-gpg")
+
(mc-pgp50-encrypt-region "mc-pgp5")
+ (mc-pgp50-fetch-key "mc-pgp5")
(mc-pgp50-lookup-key "mc-pgp5")
+ (mc-pgp50-sign-region "mc-pgp5")
+
(mc-pgp-encrypt-region "mc-pgp")
+ (mc-pgp-fetch-key "mc-pgp")
(mc-pgp-lookup-key "mc-pgp")
+ (mc-pgp-sign-region "mc-pgp")
+
(mc-snarf-keys "mc-toplev")
)))
)))
(point-max)))))
+(defun mime-mc-verify ()
+ "Verify a message in the current buffer. Exact behavior depends on
+current major mode."
+ (let ((mc-default-scheme (intern (format "mc-scheme-%s" pgp-version))))
+ (mc-verify)
+ ))
+
+(defun mime-mc-decrypt ()
+ "Decrypt a message in the current buffer. Exact behavior depends on
+current major mode."
+ (let ((mc-default-scheme (intern (format "mc-scheme-%s" pgp-version))))
+ (mc-decrypt)
+ ))
+
+(defun mime-mc-fetch-key (&optional id)
+ "Attempt to fetch a key for addition to PGP or GnuPG keyring.
+Interactively, prompt for string matching key to fetch.
+
+Non-interactively, ID must be a pair. The CAR must be a bare Email
+address and the CDR a keyID (with \"0x\" prefix). Either, but not
+both, may be nil.
+
+Return t if we think we were successful; nil otherwise. Note that nil
+is not necessarily an error, since we may have merely fired off an Email
+request for the key."
+ (funcall (intern (format "mc-%s-fetch-key" pgp-version)) id)
+ )
+
+(defun mime-mc-snarf-keys ()
+ "Add all public keys in the buffer to your keyring."
+ (let ((mc-default-scheme (intern (format "mc-scheme-%s" pgp-version))))
+ (mc-snarf-keys)
+ ))
+
+(defun mime-mc-sign-region (start end &optional id unclear boundary)
+ (funcall (intern (format "mime-mc-%s-sign-region" pgp-version))
+ start end id unclear boundary)
+ )
+
+(defun mime-mc-traditional-sign-region (start end &optional id unclear)
+ (funcall (intern (format "mc-%s-sign-region" pgp-version))
+ start end id unclear)
+ )
+
+(defun mime-mc-encrypt-region (recipients start end &optional id sign)
+ (funcall (intern (format "mime-mc-%s-encrypt-region" pgp-version))
+ recipients start end id sign)
+ )
+
(defun mime-mc-insert-public-key (&optional userid)
+ "Insert your public key at point. With one prefix arg, prompts for
+user id to use."
(let ((not-loaded (not (fboundp (intern (format "mc-%s-insert-public-key"
pgp-version)))))
(comment (mime-mc-comment))
(mime-mc-replace-comment-field comment)
)))
-(defun mime-mc-verify ()
- (let ((mc-default-scheme (intern (format "mc-scheme-%s" pgp-version))))
- (mc-verify)
- ))
-
-(defun mime-mc-decrypt ()
- (let ((mc-default-scheme (intern (format "mc-scheme-%s" pgp-version))))
- (mc-decrypt)
- ))
-
-(defun mime-mc-snarf-keys ()
- (let ((mc-default-scheme (intern (format "mc-scheme-%s" pgp-version))))
- (mc-snarf-keys)
- ))
-
;;; @ GnuPG functions
;;;
(defmacro mime-pgp-show-fetched-key (key scroll &rest args)
(` (let ((buffer (get-buffer-create "*fetched keys*"))
- start)
+ start height window shrink)
(with-current-buffer buffer
(erase-buffer)
(insert (, key))
)
(goto-char (point-min))
(forward-line (, scroll))
- (setq start (point))
+ (setq height (count-lines (point) (point-max))
+ start (point))
)
- (display-buffer buffer)
- (set-window-start (get-buffer-window buffer) start)
- )))
+ (setq window (get-buffer-window mime-echo-buffer-name))
+ (if window
+ (set-window-buffer window buffer)
+ (let (pop-up-frames)
+ (display-buffer buffer)
+ ))
+ (setq window (get-buffer-window buffer)
+ shrink (1- (- (window-height window) height)))
+ (if (> shrink 0)
+ (let ((window-min-height 1))
+ (enlarge-window shrink)
+ ))
+ (set-window-start window start)
+ buffer)))
(defun mime-pgp-show-fetched-key-for-gpg (key)
+ "Extract KEY and show. Returns buffer object to be killed."
(mime-pgp-show-fetched-key key 0)
)
(defun mime-pgp-show-fetched-key-for-pgp50 (key)
+ "Extract KEY and show. Returns buffer object to be killed."
(let ((buffer (get-buffer-create "*fetched keys*"))
(process-environment process-environment)
- process-connection-type process start)
+ process-connection-type process start height window shrink)
(setenv "PGPPASSFD" nil)
(with-current-buffer buffer
(erase-buffer)
"^Add these keys to your keyring\\? \\[Y/n\\] "
nil t))
))
+ (setq start (match-beginning 0))
(delete-process process)
+ (delete-region start (point-max))
(goto-char (point-min))
(forward-line 10)
- (setq start (point))
+ (setq height (count-lines (point) start)
+ start (point))
)
- (display-buffer buffer)
- (set-window-start (get-buffer-window buffer) start)
- ))
+ (setq window (get-buffer-window mime-echo-buffer-name))
+ (if window
+ (set-window-buffer window buffer)
+ (let (pop-up-frames)
+ (display-buffer buffer)
+ ))
+ (setq window (get-buffer-window buffer)
+ shrink (1- (- (window-height window) height)))
+ (if (> shrink 0)
+ (let ((window-min-height 1))
+ (enlarge-window shrink)
+ ))
+ (set-window-start window start)
+ buffer))
(defun mime-pgp-show-fetched-key-for-pgp (key)
+ "Extract KEY and show. Returns buffer object to be killed."
(mime-pgp-show-fetched-key key 7 "-f" "+language=en")
)
(defun mime-pgp-fetch-key (&optional id)
- "Attempt to fetch a key via HTTP for addition to PGP or GnuPG keyring.
+ "Attempt to fetch a key for addition to PGP or GnuPG keyring.
Interactively, prompt for string matching key to fetch.
Non-interactively, ID must be a pair. The CAR must be a bare Email
pgp-version)))
(snarf-function (pgp-function 'snarf-keys))
(window-config (current-window-configuration))
- case-fold-search process-connection-type process)
+ case-fold-search process-connection-type process show-buffer)
(unwind-protect
(catch 'mime-pgp-fetch-key-done
(cond ((interactive-p)
))
(progn
(delete-region (1+ (match-end 0)) (point-max))
- (funcall show-function (buffer-string))
+ (setq show-buffer
+ (funcall show-function (buffer-string))
+ )
(if (y-or-n-p "Add this key to keyring? ")
(funcall snarf-function)
- ))
+ )
+ (kill-buffer show-buffer)
+ t)
(message "Key not found.")
nil))))
+ (kill-buffer buffer)
(set-window-configuration window-config)
)))
<defvar name="pgp-function-alist">
<p>
Alist of service names vs. corresponding functions and its filenames.
-Each element looks like
-<code>(SERVICE FUNCTION FILE [PGP5_FUNCTION PGP5_FILE [GPG_FUNCTION GPG_FILE]])</code>.
+Each element looks like <code>(SERVICE FUNCTION FILE)</code>.
<p>
-SERVICE is a symbol of PGP2, PGP5 or GnuPG processing. It allows
-`verify', `decrypt', `fetch-key', `snarf-keys', `mime-sign',
-`traditional-sign', `encrypt' or `insert-key'.
+SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
+`fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
+or `insert-key'.
<p>
Function is a symbol of function to do specified SERVICE.
<p>
FILE is string of filename which has definition of corresponding
FUNCTION.
-<p>
-PGP5_FUNCTION, PGP5_FILE, GPG_FUNCTION and GPG_FILE are similar to
-FUNCTION and FILE, but they will be used for PGP 5.0i or GnuPG.
</defvar>
<defun name="pgp-function">
@defvar pgp-function-alist
Alist of service names vs. corresponding functions and its filenames.
-Each element looks like
-@code{(SERVICE FUNCTION FILE [PGP5_FUNCTION PGP5_FILE [GPG_FUNCTION GPG_FILE]])}.@refill
+Each element looks like @code{(SERVICE FUNCTION FILE)}.@refill
-SERVICE is a symbol of PGP2, PGP5 or GnuPG processing. It allows
-`verify', `decrypt', `fetch-key', `snarf-keys', `mime-sign',
-`traditional-sign', `encrypt' or `insert-key'.@refill
+SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
+`fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt' or
+`insert-key'.@refill
Function is a symbol of function to do specified SERVICE.@refill
+
FILE is string of filename which has definition of corresponding
FUNCTION.
-
-PGP5_FUNCTION, PGP5_FILE, GPG_FUNCTION and GPG_FILE are similar to
-FUNCTION and FILE, but they will be used for PGP 5.0i or GnuPG.@refill
-
@end defvar
<defvar name="pgp-function-alist">
<p>
Alist of service names vs. corresponding functions and its filenames.
-Each element looks like
-<code>(SERVICE FUNCTION FILE [PGP5_FUNCTION PGP5_FILE [GPG_FUNCTION GPG_FILE]])</code>.
+Each element looks like <code>(SERVICE FUNCTION FILE)</code>.
<p>
-SERVICE is a symbol of PGP2, PGP5 or GnuPG processing. It allows
-`verify', `decrypt', `fetch-key', `snarf-keys', `mime-sign',
-`traditional-sign', `encrypt' or `insert-key'.
+SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
+`fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
+or `insert-key'.
<p>
Function is a symbol of function to do specified SERVICE.
<p>
FILE is string of filename which has definition of corresponding
FUNCTION.
-<p>
-PGP5_FUNCTION, PGP5_FILE, GPG_FUNCTION and GPG_FILE are similar to
-FUNCTION and FILE, but they will be used for PGP 5.0i or GnuPG.
</defvar>
<defun name="pgp-function">
@defvar pgp-function-alist
Alist of service names vs. corresponding functions and its filenames.
-@code{(SERVICE FUNCTION FILE [PGP5_FUNCTION PGP5_FILE [GPG_FUNCTION GPG_FILE]])}.@refill
+Each element looks like @code{(SERVICE FUNCTION FILE)}.@refill
-SERVICE is a symbol of PGP2, PGP5 or GnuPG processing. It allows
-`verify', `decrypt', `fetch-key', `snarf-keys', `mime-sign',
-`traditional-sign', `encrypt' or `insert-key'.@refill
+SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
+`fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt' or
+`insert-key'.@refill
Function is a symbol of function to do specified SERVICE.@refill
FILE is string of filename which has definition of corresponding
FUNCTION.
-
-PGP5_FUNCTION, PGP5_FILE, GPG_FUNCTION and GPG_FILE are similar to
-FUNCTION and FILE, but they will be used for PGP 5.0i or GnuPG.@refill
@end defvar
;; for mime-pgp
(verify mime-mc-verify "mime-mc")
(decrypt mime-mc-decrypt "mime-mc")
- (fetch-key mc-pgp-fetch-key "mc-pgp"
- mc-pgp50-fetch-key "mc-pgp5"
- mc-gpg-fetch-key "mc-gpg")
+ (fetch-key mime-mc-fetch-key "mime-mc")
(snarf-keys mime-mc-snarf-keys "mime-mc")
;; for mime-edit
- (mime-sign mime-mc-pgp-sign-region "mime-mc"
- mime-mc-pgp50-sign-region "mime-mc"
- mime-mc-gpg-sign-region "mime-mc")
- (traditional-sign mc-pgp-sign-region "mc-pgp"
- mc-pgp50-sign-region "mc-pgp5"
- mc-gpg-sign-region "mc-gpg")
- (encrypt mime-mc-pgp-encrypt-region "mime-mc"
- mime-mc-pgp50-encrypt-region "mime-mc"
- mime-mc-gpg-encrypt-region "mime-mc")
+ (mime-sign mime-mc-sign-region "mime-mc")
+ (traditional-sign mime-mc-traditional-sign-region "mime-mc")
+ (encrypt mime-mc-encrypt-region "mime-mc")
(insert-key mime-mc-insert-public-key "mime-mc")
)
"Alist of service names vs. corresponding functions and its filenames.
-Each element looks like:
+Each element looks like (SERVICE FUNCTION FILE).
-\(SERVICE FUNCTION FILE [PGP5_FUNCTION PGP5_FILE [GPG_FUNCTION GPG_FILE]]).
+SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
+`fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
+or `insert-key'.
-SERVICE is a symbol of PGP2, PGP5 or GnuPG processing. It allows `verify',
-`decrypt', `fetch-key', `snarf-keys', `mime-sign', `traditional-sign',
-`encrypt' or `insert-key'.
-
-FUNCTION is a symbol of function to do specified SERVICE.
+Function is a symbol of function to do specified SERVICE.
FILE is string of filename which has definition of corresponding
-FUNCTION.
-
-PGP5_FUNCTION, PGP5_FILE, GPG_FUNCTION and GPG_FILE are similar to
-FUNCTION and FILE, but they will be used for PGP 5.0i or GnuPG.")
+FUNCTION.")
(defmacro pgp-function (method)
"Return function to do service METHOD."
- `(let ((elem (assq ,method (symbol-value 'pgp-function-alist))))
- (cond ((eq 'gpg pgp-version)
- (if (> (length elem) 3)
- (nth 5 elem)
- (nth 1 elem))
- )
- ((eq 'pgp50 pgp-version)
- (if (> (length elem) 3)
- (nth 3 elem)
- (nth 1 elem))
- )
- (t
- (nth 1 elem)
- ))))
+ `(cadr (assq ,method (symbol-value 'pgp-function-alist))))
(mapcar (function
- (lambda (elem)
- (setq elem (cdr elem))
- (while elem
- (autoload (car elem) (nth 1 elem))
- (setq elem (nthcdr 2 elem)))))
+ (lambda (method)
+ (autoload (cadr method)(nth 2 method))
+ ))
pgp-function-alist)