aboutsummaryrefslogtreecommitdiff
path: root/lisp/magit-commit.el
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2021-02-06 13:36:57 +0100
committerJonas Bernoulli <jonas@bernoul.li>2021-02-06 13:36:57 +0100
commit386909763852dac368541fe9d220707124bff99e (patch)
tree0a45f036da4c890d4623d8ddbb2fdcd8bdd6c33f /lisp/magit-commit.el
parent7f681aee0d6616be789c6ee72b23dba51ad4f848 (diff)
magit-read-gpg-secret-key: Add optional predicate argument
Diffstat (limited to 'lisp/magit-commit.el')
-rw-r--r--lisp/magit-commit.el35
1 files changed, 20 insertions, 15 deletions
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index 7c45cc6..365e3a3 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -148,23 +148,28 @@ Also see `git-commit-post-finish-hook'."
(defvar magit-gpg-secret-key-hist nil)
-(defun magit-read-gpg-secret-key (prompt &optional initial-input history)
+(defun magit-read-gpg-secret-key
+ (prompt &optional initial-input history predicate)
(require 'epa)
- (let* ((keys (mapcar
+ (let* ((keys (mapcan
(lambda (cert)
- (let* ((key (car (epg-key-sub-key-list cert)))
- (fpr (epg-sub-key-fingerprint key))
- (id (epg-sub-key-id key))
- (author
- (when-let ((id-obj (car (epg-key-user-id-list cert))))
- (let ((id-str (epg-user-id-string id-obj)))
- (if (stringp id-str)
- id-str
- (epg-decode-dn id-obj))))))
- (propertize fpr 'display
- (concat (substring fpr 0 (- (length id)))
- (propertize id 'face 'highlight)
- " " author))))
+ (and (or (not predicate)
+ (funcall predicate cert))
+ (let* ((key (car (epg-key-sub-key-list cert)))
+ (fpr (epg-sub-key-fingerprint key))
+ (id (epg-sub-key-id key))
+ (author
+ (when-let ((id-obj
+ (car (epg-key-user-id-list cert))))
+ (let ((id-str (epg-user-id-string id-obj)))
+ (if (stringp id-str)
+ id-str
+ (epg-decode-dn id-obj))))))
+ (list
+ (propertize fpr 'display
+ (concat (substring fpr 0 (- (length id)))
+ (propertize id 'face 'highlight)
+ " " author))))))
(epg-list-keys (epg-make-context epa-protocol) nil t)))
(choice (completing-read prompt keys nil nil nil
history nil initial-input)))