Function: magit-read-gpg-secret-key

magit-read-gpg-secret-key is a byte-compiled function defined in magit.el.

Signature

(magit-read-gpg-secret-key PROMPT &optional INITIAL-INPUT HISTORY PREDICATE DEFAULT)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit.el
(defun magit-read-gpg-secret-key
    (prompt &optional initial-input history predicate default)
  (require 'epa)
  (let* ((keys (seq-keep
                (lambda (cert)
                  (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
                               (and-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)))))
                (epg-list-keys (epg-make-context epa-protocol) nil t)))
         (choice (or (and (not current-prefix-arg)
                          (or (and (length= keys 1) (car keys))
                              (and default (car (member default keys)))))
                     (completing-read prompt keys nil nil nil
                                      history nil initial-input))))
    (set-text-properties 0 (length choice) nil choice)
    choice))