From: ueno Date: Fri, 5 Jan 2007 22:28:30 +0000 (+0000) Subject: * epa.el (epa-key-list-mode-map): Renamed from epa-keys-mode-map. X-Git-Tag: epg-0_0_10~17 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52922bf3f8d3b7f4fee3359b18a5c03d2fac71c2;p=elisp%2Fepg.git * epa.el (epa-key-list-mode-map): Renamed from epa-keys-mode-map. (epa-key-list-mode): Renamed from epa-keys-mode. All callers changed. * epg.el (epg--status-VALIDSIG): Don't set expiration-time if it is "0". --- diff --git a/ChangeLog b/ChangeLog index 2b15539..be6aa66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2007-01-05 Daiki Ueno + * epa.el (epa-key-list-mode-map): Renamed from epa-keys-mode-map. + (epa-key-list-mode): Renamed from epa-keys-mode. All callers + changed. + + * epg.el (epg--status-VALIDSIG): Don't set expiration-time if it + is "0". + * pgg-epg.el (pgg-epg-encrypt-region): Ask a user whether to skip a recipient whose public key is not available. * epa.el (epa-encrypt-mail): Ask a user whether to skip a diff --git a/epa.el b/epa.el index d5d8298..6f38d70 100644 --- a/epa.el +++ b/epa.el @@ -181,7 +181,7 @@ the separate window." (defvar epa-info-buffer nil) (defvar epa-last-coding-system-specified nil) -(defvar epa-keys-mode-map +(defvar epa-key-list-mode-map (let ((keymap (make-sparse-keymap))) (define-key keymap "m" 'epa-mark) (define-key keymap "u" 'epa-unmark) @@ -260,22 +260,22 @@ the separate window." (defalias 'epa--decode-coding-string 'decode-coding-string) (defalias 'epa--decode-coding-string 'identity)) -(defun epa-keys-mode () +(defun epa-key-list-mode () "Major mode for `epa-list-keys'." (kill-all-local-variables) (buffer-disable-undo) - (setq major-mode 'epa-keys-mode + (setq major-mode 'epa-key-list-mode mode-name "Keys" truncate-lines t buffer-read-only t) - (use-local-map epa-keys-mode-map) + (use-local-map epa-key-list-mode-map) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(epa-font-lock-keywords t)) ;; In XEmacs, auto-initialization of font-lock is not effective ;; if buffer-file-name is not set. (font-lock-set-defaults) (make-local-variable 'epa-exit-buffer-function) - (run-hooks 'epa-keys-mode-hook)) + (run-hooks 'epa-key-list-mode-hook)) (defun epa-key-mode () "Major mode for a key description." @@ -353,6 +353,7 @@ reads the public keyring." (buffer-live-p epa-keys-buffer)) (setq epa-keys-buffer (generate-new-buffer "*Keys*"))) (set-buffer epa-keys-buffer) + (epa-key-list-mode) (let ((inhibit-read-only t) buffer-read-only (point (point-min)) @@ -365,7 +366,6 @@ reads the public keyring." (point-max))) (goto-char point)) (epa--insert-keys context name mode) - (epa-keys-mode) (widget-setup) (set-keymap-parent (current-local-map) widget-keymap)) (make-local-variable 'epa-list-keys-arguments) @@ -426,11 +426,15 @@ If SECRET is non-nil, list secret keys instead of public keys." (unless (and epa-keys-buffer (buffer-live-p epa-keys-buffer)) (setq epa-keys-buffer (generate-new-buffer "*Keys*"))) + (set-buffer epa-keys-buffer) + (epa-key-list-mode) (let ((inhibit-read-only t) buffer-read-only) - (set-buffer epa-keys-buffer) (erase-buffer) - (insert prompt "\n") + (insert prompt "\n" + (substitute-command-keys + "- `\\[epa-mark]' to mark a key on the line\n" + "- `\\[epa-unmark]' to unmark a key on the line\n")) (widget-create 'link :notify (lambda (&rest ignore) (abort-recursive-edit)) :help-echo @@ -457,7 +461,6 @@ If SECRET is non-nil, list secret keys instead of public keys." (if (get-text-property (point) 'epa-list-keys) (epa-mark))) (epa--insert-keys context nil nil))) - (epa-keys-mode) (widget-setup) (set-keymap-parent (current-local-map) widget-keymap) (setq epa-exit-buffer-function #'abort-recursive-edit) @@ -506,6 +509,7 @@ If SECRET is non-nil, list secret keys instead of public keys." (setcdr entry (generate-new-buffer (format "*Key*%s" (epg-sub-key-id primary-sub-key))))) (set-buffer (cdr entry)) + (epa-key-mode) (make-local-variable 'epa-key) (setq epa-key key) (erase-buffer) @@ -558,8 +562,7 @@ If SECRET is non-nil, list secret keys instead of public keys." "\n") (setq pointer (cdr pointer))) (goto-char (point-min)) - (pop-to-buffer (current-buffer)) - (epa-key-mode))) + (pop-to-buffer (current-buffer)))) (defun epa-display-info (info) (if epa-popup-info-window @@ -817,20 +820,6 @@ Don't use this command in Lisp programs!" (epa-decrypt-region armor-start armor-end))))))) ;;;###autoload -(defun epa-decrypt-mail () - "Decrypt OpenPGP armors in the current buffer. -The buffer is expected to contain a mail message. - -Don't use this command in Lisp programs!" - (interactive) - (epa-decrypt-armor-in-region (point-min) (point-max))) - -(if (fboundp 'select-safe-coding-system) - (defalias 'epa--select-safe-coding-system 'select-safe-coding-system) - (defun epa--select-safe-coding-system (from to) - buffer-file-coding-system)) - -;;;###autoload (defun epa-verify-region (start end) "Verify the current region between START and END. @@ -876,15 +865,6 @@ Don't use this command in Lisp programs!" (epa-verify-region armor-start armor-end)))))) ;;;###autoload -(defun epa-verify-mail () - "Verify OpenPGP cleartext signed messages in the current buffer. -The buffer is expected to contain a mail message. - -Don't use this command in Lisp programs!" - (interactive) - (epa-verify-cleartext-in-region (point-min) (point-max))) - -;;;###autoload (defun epa-sign-region (start end signers mode) "Sign the current region between START and END by SIGNERS keys selected. @@ -950,40 +930,6 @@ Uses the `derived-mode-parent' property of the symbol to trace backwards." (setq parent (get parent 'derived-mode-parent)))) parent))) -(defun epa--mail-mode-p () - (let ((pointer epa-mail-modes)) - (while (and pointer - (epa--derived-mode-p (car pointer))) - (setq pointer (cdr pointer))) - pointer)) - -;;;###autoload -(defun epa-sign-mail (start end signers mode) - "Sign the current buffer. -The buffer is expected to contain a mail message. - -Don't use this command in Lisp programs!" - (interactive - (save-excursion - (goto-char (point-min)) - (if (and (epa--mail-mode-p) - (search-forward mail-header-separator nil t)) - (forward-line)) - (setq epa-last-coding-system-specified - (or coding-system-for-write - (epa--select-safe-coding-system (point) (point-max)))) - (let ((verbose current-prefix-arg)) - (list (point) (point-max) - (if verbose - (epa-select-keys (epg-make-context epa-protocol) - "Select keys for signing. -If no one is selected, default secret key is used. " - nil t)) - (if verbose - (epa--read-signature-type) - 'clear))))) - (epa-sign-region start end signers mode)) - ;;;###autoload (defun epa-encrypt-region (start end recipients sign signers) "Encrypt the current region between START and END for RECIPIENTS. @@ -1041,69 +987,6 @@ If no one is selected, symmetric encryption will be performed. ") 'end-open t))))) ;;;###autoload -(defun epa-encrypt-mail (start end recipients sign signers) - "Encrypt the current buffer. -The buffer is expected to contain a mail message. - -Don't use this command in Lisp programs!" - (interactive - (save-excursion - (let ((verbose current-prefix-arg) - (context (epg-make-context epa-protocol)) - recipients recipient-keys) - (goto-char (point-min)) - (when (epa--mail-mode-p) - (save-restriction - (narrow-to-region (point) - (if (search-forward mail-header-separator nil 0) - (match-beginning 0) - (point))) - (setq recipients - (mail-strip-quoted-names - (mapconcat #'identity - (nconc (mail-fetch-field "to" nil nil t) - (mail-fetch-field "cc" nil nil t) - (mail-fetch-field "bcc" nil nil t)) - ",")))) - (if recipients - (setq recipients (delete "" - (split-string recipients "[ \t\n]+")))) - (goto-char (point-min)) - (if (search-forward mail-header-separator nil t) - (forward-line))) - (setq epa-last-coding-system-specified - (or coding-system-for-write - (epa--select-safe-coding-system (point) (point-max)))) - (list (point) (point-max) - (if verbose - (epa-select-keys - context - "Select recipients for encryption. -If no one is selected, symmetric encryption will be performed. " - recipients) - (if recipients - (apply #'nconc - (mapcar - (lambda (recipient) - (setq recipient-keys - (epg-list-keys - (epg-make-context epa-protocol) - (concat "<" recipient ">"))) - (unless (or recipient-keys - (y-or-n-p - (format - "No public key for %s; skip it? " - recipient))) - (error "No public key for %s" recipient)) - recipient-keys) - recipients)))) - (setq sign (if verbose (y-or-n-p "Sign? "))) - (if sign - (epa-select-keys context - "Select keys for signing. ")))))) - (epa-encrypt-region start end recipients sign signers)) - -;;;###autoload (defun epa-delete-keys (keys &optional allow-secret) "Delete selected KEYS. @@ -1138,7 +1021,7 @@ Don't use this command in Lisp programs!" (if (epg-context-result-for context 'import) (epa-display-info (epg-import-result-to-string (epg-context-result-for context 'import)))) - (if (eq major-mode 'epa-keys-mode) + (if (eq major-mode 'epa-key-list-mode) (apply #'epa-list-keys epa-list-keys-arguments)))) ;;;###autoload @@ -1183,15 +1066,6 @@ Don't use this command in Lisp programs!" (epa-import-keys-region armor-start armor-end)))))) ;;;###autoload -(defun epa-import-mail () - "Import keys in the OpenPGP armor format in the current buffer. -The buffer is expected to contain a mail message. - -Don't use this command in Lisp programs!" - (interactive) - (epa-import-armor-in-region (point-min) (point-max))) - -;;;###autoload (defun epa-export-keys (keys file) "Export selected KEYS to FILE. @@ -1255,6 +1129,135 @@ Don't use this command in Lisp programs!" (message "Signing keys...done"))) (make-obsolete 'epa-sign-keys "Do not use.") +;;;###autoload +(defun epa-decrypt-mail () + "Decrypt OpenPGP armors in the current buffer. +The buffer is expected to contain a mail message. + +Don't use this command in Lisp programs!" + (interactive) + (epa-decrypt-armor-in-region (point-min) (point-max))) + +(if (fboundp 'select-safe-coding-system) + (defalias 'epa--select-safe-coding-system 'select-safe-coding-system) + (defun epa--select-safe-coding-system (from to) + buffer-file-coding-system)) + +;;;###autoload +(defun epa-verify-mail () + "Verify OpenPGP cleartext signed messages in the current buffer. +The buffer is expected to contain a mail message. + +Don't use this command in Lisp programs!" + (interactive) + (epa-verify-cleartext-in-region (point-min) (point-max))) + +(defun epa--mail-mode-p () + (let ((pointer epa-mail-modes)) + (while (and pointer + (epa--derived-mode-p (car pointer))) + (setq pointer (cdr pointer))) + pointer)) + +;;;###autoload +(defun epa-sign-mail (start end signers mode) + "Sign the current buffer. +The buffer is expected to contain a mail message. + +Don't use this command in Lisp programs!" + (interactive + (save-excursion + (goto-char (point-min)) + (if (and (epa--mail-mode-p) + (search-forward mail-header-separator nil t)) + (forward-line)) + (setq epa-last-coding-system-specified + (or coding-system-for-write + (epa--select-safe-coding-system (point) (point-max)))) + (let ((verbose current-prefix-arg)) + (list (point) (point-max) + (if verbose + (epa-select-keys (epg-make-context epa-protocol) + "Select keys for signing. +If no one is selected, default secret key is used. " + nil t)) + (if verbose + (epa--read-signature-type) + 'clear))))) + (epa-sign-region start end signers mode)) + +;;;###autoload +(defun epa-encrypt-mail (start end recipients sign signers) + "Encrypt the current buffer. +The buffer is expected to contain a mail message. + +Don't use this command in Lisp programs!" + (interactive + (save-excursion + (let ((verbose current-prefix-arg) + (context (epg-make-context epa-protocol)) + recipients recipient-keys) + (goto-char (point-min)) + (when (epa--mail-mode-p) + (save-restriction + (narrow-to-region (point) + (if (search-forward mail-header-separator nil 0) + (match-beginning 0) + (point))) + (setq recipients + (mail-strip-quoted-names + (mapconcat #'identity + (nconc (mail-fetch-field "to" nil nil t) + (mail-fetch-field "cc" nil nil t) + (mail-fetch-field "bcc" nil nil t)) + ",")))) + (if recipients + (setq recipients (delete "" + (split-string recipients "[ \t\n]+")))) + (goto-char (point-min)) + (if (search-forward mail-header-separator nil t) + (forward-line))) + (setq epa-last-coding-system-specified + (or coding-system-for-write + (epa--select-safe-coding-system (point) (point-max)))) + (list (point) (point-max) + (if verbose + (epa-select-keys + context + "Select recipients for encryption. +If no one is selected, symmetric encryption will be performed. " + recipients) + (if recipients + (apply #'nconc + (mapcar + (lambda (recipient) + (setq recipient-keys + (epg-list-keys + (epg-make-context epa-protocol) + (concat "<" recipient ">"))) + (unless (or recipient-keys + (y-or-n-p + (format + "No public key for %s; skip it? " + recipient))) + (error "No public key for %s" recipient)) + recipient-keys) + recipients)))) + (setq sign (if verbose (y-or-n-p "Sign? "))) + (if sign + (epa-select-keys context + "Select keys for signing. ")))))) + (epa-encrypt-region start end recipients sign signers)) + +;;;###autoload +(defun epa-import-mail () + "Import keys in the OpenPGP armor format in the current buffer. +The buffer is expected to contain a mail message. + +Don't use this command in Lisp programs!" + (interactive) + (epa-import-armor-in-region (point-min) (point-max))) + (provide 'epa) ;;; epa.el ends here diff --git a/epg.el b/epg.el index 5263632..243292c 100644 --- a/epg.el +++ b/epg.el @@ -1378,9 +1378,10 @@ This function is for internal use only." (epg-signature-set-creation-time signature (epg--time-from-seconds (match-string 2 string))) - (epg-signature-set-expiration-time - signature - (epg--time-from-seconds (match-string 3 string))) + (unless (equal (match-string 3 string) "0") + (epg-signature-set-expiration-time + signature + (epg--time-from-seconds (match-string 3 string)))) (epg-signature-set-version signature (string-to-number (match-string 4 string)))