From: Aleksandr Vityazev via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 69133@debbugs.gnu.org
Subject: bug#69133: [PATCH] Make key selection method configurable in EPA.
Date: Wed, 14 Feb 2024 22:47:08 +0300 [thread overview]
Message-ID: <875xyqbzgj.fsf@disroot.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 234 bytes --]
Tags: patch
Hi,
Currently in epa.el it is possible to select keys only through a
separate buffer, I think adding the option to select via minibuffer
would be a nice addition. The current behavior is set to default. Any
comments?
[-- Attachment #2: 0001-Make-key-selection-method-configurable-in-EPA.patch --]
[-- Type: text/patch, Size: 3172 bytes --]
From 95e277514bc7b92858b92dacca66683dd31e6da2 Mon Sep 17 00:00:00 2001
Message-ID: <95e277514bc7b92858b92dacca66683dd31e6da2.1707939800.git.avityazev@disroot.org>
From: Aleksandr Vityazev <avityazev@disroot.org>
Date: Wed, 14 Feb 2024 22:43:04 +0300
Subject: [PATCH] Make key selection method configurable in EPA.
* lisp/epa.el (epa-keys-select-method): New defcustom.
(epa--select-keys-in-minibuffer): New function.
(epa-select-keys): Use new option and function.
* etc/NEWS: Document it.
---
etc/NEWS | 8 ++++++++
lisp/epa.el | 30 +++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index e6b1d424499..6cd7c82b69f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1352,6 +1352,14 @@ characters, such as ½ (U+00BD VULGAR FRACTION ONE HALF), are also
recognized as rational fractions. They have been since 2004, but it
looks like it was never mentioned in the NEWS, or even the manual.
+** EasyPG
+
+---
+*** New user option 'epa-keys-select-method'
+This allows the user to customize the key selection method, a minibuffer
+or buffer option is available, which is set by default and was used in
+all earlier versions.
+
\f
* New Modes and Packages in Emacs 30.1
diff --git a/lisp/epa.el b/lisp/epa.el
index 53da3bf6cce..f78866c6eef 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -73,6 +73,18 @@ epa-mail-aliases
:group 'epa
:version "24.4")
+(defcustom epa-keys-select-method 'buffer
+ "Method used to select keys.
+It can have two values: buffer or minibuffer.
+Can have two values: buffer or minibuffer. In the first case, the keys
+can be selected via a pop-up buffer. In the second case, the keys
+can be selected via a minibuffer and `completing-read-multiple' will be
+used."
+ :type '(choice (const :tag "Read keys from buffer" buffer)
+ (const :tag "Read keys from minibuffer" minibuffer))
+ :group 'epa
+ :version "30.1")
+
;;; Faces
(defgroup epa-faces nil
@@ -450,6 +462,19 @@ epa--select-keys
(epa--marked-keys))
(kill-buffer epa-keys-buffer)))))
+(defun epa--select-keys-in-minibuffer (prompt keys)
+ (let* ((keys-alist
+ (seq-map
+ (lambda (key)
+ (cons (substring-no-properties
+ (epa--button-key-text key))
+ key))
+ keys))
+ (selected-keys (completing-read-multiple prompt keys-alist)))
+ (seq-map
+ (lambda (key) (cdr (assoc key keys-alist)))
+ selected-keys)))
+
;;;###autoload
(defun epa-select-keys (context prompt &optional names secret)
"Display a user's keyring and ask him to select keys.
@@ -459,7 +484,10 @@ epa-select-keys
the keys are listed.
If SECRET is non-nil, list secret keys instead of public keys."
(let ((keys (epg-list-keys context names secret)))
- (epa--select-keys prompt keys)))
+ (pcase epa-keys-select-method
+ ('buffer (epa--select-keys prompt keys))
+ ('minibuffer (epa--select-keys-in-minibuffer prompt keys))
+ (_ (error "Wrong method for key selection is specified")))))
;;;; Key Details
--
2.41.0
[-- Attachment #3: Type: text/plain, Size: 38 bytes --]
--
Best regards,
Aleksandr Vityazev
next reply other threads:[~2024-02-14 19:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 19:47 Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-02-15 6:07 ` bug#69133: [PATCH] Make key selection method configurable in EPA Eli Zaretskii
2024-02-15 20:22 ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17 9:32 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875xyqbzgj.fsf@disroot.org \
--to=bug-gnu-emacs@gnu.org \
--cc=69133@debbugs.gnu.org \
--cc=avityazev@disroot.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.