[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit f365aa48c4 11/13: Move shared infix argument ma
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit f365aa48c4 11/13: Move shared infix argument magit:--gpg-sign to magit.el |
Date: |
Fri, 6 May 2022 15:58:12 -0400 (EDT) |
branch: elpa/git-commit
commit f365aa48c4da614d8b5c6940bd147b53316227a0
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Move shared infix argument magit:--gpg-sign to magit.el
Bring some things along.
This helps avoiding circular dependencies.
---
lisp/magit-commit.el | 63 ------------------------------------------------
lisp/magit.el | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 63 deletions(-)
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index c56246a1f9..081b8e78a5 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -31,9 +31,6 @@
(require 'magit)
(require 'magit-sequence)
-(eval-when-compile (require 'epa)) ; for `epa-protocol'
-(eval-when-compile (require 'epg))
-
;;; Options
(defcustom magit-commit-ask-to-stage 'verbose
@@ -116,16 +113,6 @@ Also see https://github.com/magit/magit/issues/4132."
:group 'magit-commands
:type 'boolean)
-(defcustom magit-openpgp-default-signing-key nil
- "Fingerprint of your default Openpgp key used for signing.
-If the specified primary key has signing capacity then it is used
-as the value of the `--gpg-sign' argument without prompting, even
-when other such keys exist. To be able to select another key you
-must then use a prefix argument."
- :package-version '(magit . "3.4.0")
- :group 'magit-commands
- :type 'string)
-
;;; Popup
;;;###autoload (autoload 'magit-commit "magit-commit" nil t)
@@ -168,56 +155,6 @@ must then use a prefix argument."
(defun magit-commit-arguments nil
(transient-args 'magit-commit))
-(transient-define-argument magit:--gpg-sign ()
- :description "Sign using gpg"
- :class 'transient-option
- :shortarg "-S"
- :argument "--gpg-sign="
- :allow-empty t
- :reader #'magit-read-gpg-signing-key)
-
-(defvar magit-gpg-secret-key-hist nil)
-
-(defun magit-read-gpg-secret-key
- (prompt &optional initial-input history predicate default)
- (require 'epa)
- (let* ((keys (cl-mapcan
- (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))))))
- (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 (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))
-
-(defun magit-read-gpg-signing-key (prompt &optional initial-input history)
- (magit-read-gpg-secret-key
- prompt initial-input history
- (lambda (cert)
- (cl-some (lambda (key)
- (memq 'sign (epg-sub-key-capability key)))
- (epg-key-sub-key-list cert)))
- magit-openpgp-default-signing-key))
-
(transient-define-argument magit-commit:--reuse-message ()
:description "Reuse commit message"
:class 'transient-option
diff --git a/lisp/magit.el b/lisp/magit.el
index dc4a533114..75d319c237 100644
--- a/lisp/magit.el
+++ b/lisp/magit.el
@@ -72,6 +72,22 @@
(require 'package nil t) ; used in `magit-version'
(require 'with-editor)
+;; For `magit:--gpg-sign'
+(declare-function epg-list-keys "epg" (context &optional name mode))
+(declare-function epg-decode-dn "epg" (alist))
+
+;;; Options
+
+(defcustom magit-openpgp-default-signing-key nil
+ "Fingerprint of your default Openpgp key used for signing.
+If the specified primary key has signing capacity then it is used
+as the value of the `--gpg-sign' argument without prompting, even
+when other such keys exist. To be able to select another key you
+must then use a prefix argument."
+ :package-version '(magit . "3.4.0")
+ :group 'magit-commands
+ :type 'string)
+
;;; Faces
(defface magit-header-line
@@ -471,6 +487,58 @@ is run in the top-level directory of the current working
tree."
"Async shell command: ")
initial-input 'magit-git-command-history)))
+;;; Shared Infix Arguments
+
+(transient-define-argument magit:--gpg-sign ()
+ :description "Sign using gpg"
+ :class 'transient-option
+ :shortarg "-S"
+ :argument "--gpg-sign="
+ :allow-empty t
+ :reader #'magit-read-gpg-signing-key)
+
+(defvar magit-gpg-secret-key-hist nil)
+
+(defun magit-read-gpg-secret-key
+ (prompt &optional initial-input history predicate default)
+ (require 'epa)
+ (let* ((keys (cl-mapcan
+ (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))))))
+ (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 (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))
+
+(defun magit-read-gpg-signing-key (prompt &optional initial-input history)
+ (magit-read-gpg-secret-key
+ prompt initial-input history
+ (lambda (cert)
+ (cl-some (lambda (key)
+ (memq 'sign (epg-sub-key-capability key)))
+ (epg-key-sub-key-list cert)))
+ magit-openpgp-default-signing-key))
+
;;; Font-Lock Keywords
(defconst magit-font-lock-keywords
- [nongnu] elpa/git-commit 2d679dff02 10/13: Move definition of magit-tramp-process-environment, (continued)
- [nongnu] elpa/git-commit 2d679dff02 10/13: Move definition of magit-tramp-process-environment, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit e35f2b9be7 09/13: magit-blame.el: Move internal variables to beginning of file, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 42a954adb4 03/13: Remove unnecessary variable declaration, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit ce29c373b9 08/13: magit-section.el: Move internal variables to beginning of file, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 632536ca9c 07/13: Add magit-status-goto-initial-section to magit-create-buffer-hook, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit cc07643bb1 12/13: Use fboundp instead of declare-function for magit-blame functions, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 6c98ba3dac 13/13: Use fboundp instead of requiring magit-wip, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 16aa4340c8 02/13: Add missing section headings, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit 85e169736e 05/13: magit-refresh: No longer hardcode dedicated post-command hooks, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit c3268fc69d 04/13: git-commit.el: Rearrange dependencies, ELPA Syncer, 2022/05/06
- [nongnu] elpa/git-commit f365aa48c4 11/13: Move shared infix argument magit:--gpg-sign to magit.el,
ELPA Syncer <=