(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)
(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."
(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))
(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)
(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
(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)
(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)
"\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
(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.
(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.
(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.
'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.
(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
(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.
(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