(defvar epa-key-list-mode-map
(let ((keymap (make-sparse-keymap)))
- (define-key keymap "m" 'epa-mark)
- (define-key keymap "u" 'epa-unmark)
+ (define-key keymap "m" 'epa-mark-key)
+ (define-key keymap "u" 'epa-unmark-key)
(define-key keymap "d" 'epa-decrypt-file)
(define-key keymap "v" 'epa-verify-file)
(define-key keymap "s" 'epa-sign-file)
(epg-sub-key-id (car (epg-key-sub-key-list
(widget-get widget :value))))))
-(if (fboundp 'encode-coding-string)
- (defalias 'epa--encode-coding-string 'encode-coding-string)
- (defalias 'epa--encode-coding-string 'identity))
+(eval-and-compile
+ (if (fboundp 'encode-coding-string)
+ (defalias 'epa--encode-coding-string 'encode-coding-string)
+ (defalias 'epa--encode-coding-string 'identity)))
-(if (fboundp 'decode-coding-string)
- (defalias 'epa--decode-coding-string 'decode-coding-string)
- (defalias 'epa--decode-coding-string 'identity))
+(eval-and-compile
+ (if (fboundp 'decode-coding-string)
+ (defalias 'epa--decode-coding-string 'decode-coding-string)
+ (defalias 'epa--decode-coding-string 'identity)))
(defun epa-key-list-mode ()
"Major mode for `epa-list-keys'."
(use-local-map epa-info-mode-map)
(run-hooks 'epa-info-mode-hook))
-(defun epa-mark (&optional arg)
- "Mark the current line.
-If ARG is non-nil, unmark the current line."
+(defun epa-mark-key (&optional arg)
+ "Mark a key on the current line.
+If ARG is non-nil, unmark the key."
(interactive "P")
(let ((inhibit-read-only t)
buffer-read-only
properties)
(beginning-of-line)
+ (unless (get-text-property (point) 'epa-key)
+ (error "No key on this line"))
(setq properties (text-properties-at (point)))
(delete-char 1)
(insert (if arg " " "*"))
(set-text-properties (1- (point)) (point) properties)
(forward-line)))
-(defun epa-unmark (&optional arg)
- "Unmark the current line.
-If ARG is non-nil, mark the current line."
+(defun epa-unmark-key (&optional arg)
+ "Unmark a key on the current line.
+If ARG is non-nil, mark the key."
(interactive "P")
- (epa-mark (not arg)))
-
-(defun epa-toggle-mark ()
- "Toggle the mark the current line."
- (interactive)
- (epa-mark (eq (char-after (save-excursion (beginning-of-line) (point))) ?*)))
+ (epa-mark-key (not arg)))
(defun epa-exit-buffer ()
"Exit the current buffer.
(if key
(list key))))))
-;;;###autoload
-(defun epa-select-keys (context prompt &optional names secret)
- "Display a user's keyring and ask him to select keys.
-CONTEXT is an epg-context.
-PROMPT is a string to prompt with.
-NAMES is a list of strings to be matched with keys. If it is nil, all
-the keys are listed.
-If SECRET is non-nil, list secret keys instead of public keys."
+(defun epa--select-keys (prompt keys)
(save-excursion
(unless (and epa-keys-buffer
(buffer-live-p epa-keys-buffer))
(erase-buffer)
(insert prompt "\n"
(substitute-command-keys "\
-- `\\[epa-mark]' to mark a key on the line
-- `\\[epa-unmark]' to unmark a key on the line\n"))
+- `\\[epa-mark-key]' to mark a key on the line
+- `\\[epa-unmark-key]' to unmark a key on the line\n"))
(widget-create 'link
:notify (lambda (&rest ignore) (abort-recursive-edit))
:help-echo
"Click here or \\[exit-recursive-edit] to finish")
"OK")
(insert "\n\n")
- (epa--insert-keys (epg-list-keys context name mode))
+ (epa--insert-keys keys)
(widget-setup)
(set-keymap-parent (current-local-map) widget-keymap)
(setq epa-exit-buffer-function #'abort-recursive-edit)
(delete-window (get-buffer-window epa-keys-buffer)))
(kill-buffer epa-keys-buffer))))
+;;;###autoload
+(defun epa-select-keys (context prompt &optional names secret)
+ "Display a user's keyring and ask him to select keys.
+CONTEXT is an epg-context.
+PROMPT is a string to prompt with.
+NAMES is a list of strings to be matched with keys. If it is nil, all
+the keys are listed.
+If SECRET is non-nil, list secret keys instead of public keys."
+ (let ((keys (epg-list-keys context names secret)))
+ (if (> (length keys) 1)
+ (epa--select-keys prompt keys)
+ keys)))
+
(defun epa--format-fingerprint-1 (fingerprint unit-size block-size)
(let ((unit 0))
(with-temp-buffer
(error "No cleartext tail"))
(epa-verify-region cleartext-start cleartext-end))))))
-(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))
+(eval-and-compile
+ (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-sign-region (start end signers mode)
'start-open t
'end-open t)))))
-(if (fboundp 'derived-mode-p)
- (defalias 'epa--derived-mode-p 'derived-mode-p)
- (defun epa--derived-mode-p (&rest modes)
- "Non-nil if the current major mode is derived from one of MODES.
+(eval-and-compile
+ (if (fboundp 'derived-mode-p)
+ (defalias 'epa--derived-mode-p 'derived-mode-p)
+ (defun epa--derived-mode-p (&rest modes)
+ "Non-nil if the current major mode is derived from one of MODES.
Uses the `derived-mode-parent' property of the symbol to trace backwards."
- (let ((parent major-mode))
- (while (and (not (memq parent modes))
- (setq parent (get parent 'derived-mode-parent))))
- parent)))
+ (let ((parent major-mode))
+ (while (and (not (memq parent modes))
+ (setq parent (get parent 'derived-mode-parent))))
+ parent))))
;;;###autoload
(defun epa-encrypt-region (start end recipients sign signers)