From unknown Mon Jun 23 02:26:34 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69133: [PATCH] Make key selection method configurable in EPA. Resent-From: Aleksandr Vityazev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Feb 2024 19:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 69133@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17079400636126 (code B ref -1); Wed, 14 Feb 2024 19:48:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Feb 2024 19:47:43 +0000 Received: from localhost ([127.0.0.1]:53162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raLEN-0001ak-CL for submit@debbugs.gnu.org; Wed, 14 Feb 2024 14:47:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:35840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raLEL-0001ac-JZ for submit@debbugs.gnu.org; Wed, 14 Feb 2024 14:47:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raLE3-0000EW-3X for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:47:23 -0500 Received: from layka.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raLE0-0000sU-Mv for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:47:22 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6D4D544DFC for ; Wed, 14 Feb 2024 20:47:17 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FWfZh5z_kWQE for ; Wed, 14 Feb 2024 20:47:16 +0100 (CET) From: Aleksandr Vityazev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1707940036; bh=D3OwXG5ljeRR5YPjEJKZjW1gfKnMfo9+q+bnO6jEdOQ=; h=From:To:Subject:Date; b=eP31X3ct72WDLyegWU67/lGSlkARKybS2wVo2Hj9f9PlMh658YgAp7CDuw0PBRzqU dVq7/fG+CDBqsU9GZtSzYT04xenL+OuGafdoAxmLlpjB370cPVv4zqJHCWsdj8rJLZ Fyx5Lws0Y229woHXHV+2EBoIJlIjzS6lhleEpRMubOVrphrHCe6YFPiRFiZVOcyCTP YQFHpgR3nsK7qTSjYTbFVP3srB5siq6tdS8ctPjY9C4Qh1xahIrhMyJEzq+ohGbRjU mbMzjjimtgl5cdjmgIWWUsZcwWkrhpZpe5DUP8wL9lLDe/eCIDGSuXo+e51oLL8N4O ykxMyuHShMHsw== Date: Wed, 14 Feb 2024 22:47:08 +0300 Message-ID: <875xyqbzgj.fsf@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=178.21.23.139; envelope-from=avityazev@disroot.org; helo=layka.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.2 (-----) --=-=-= Content-Type: text/plain 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? --=-=-= Content-Type: text/patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Make-key-selection-method-configurable-in-EPA.patch Content-Transfer-Encoding: quoted-printable >From 95e277514bc7b92858b92dacca66683dd31e6da2 Mon Sep 17 00:00:00 2001 Message-ID: <95e277514bc7b92858b92dacca66683dd31e6da2.1707939800.git.avitya= zev@disroot.org> From: Aleksandr Vityazev 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 =C2=BD (U+00BD VULGAR FRACTION O= NE 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. + * 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 --=-=-= Content-Type: text/plain -- Best regards, Aleksandr Vityazev --=-=-=-- From unknown Mon Jun 23 02:26:34 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69133: [PATCH] Make key selection method configurable in EPA. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Feb 2024 06:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Aleksandr Vityazev Cc: 69133@debbugs.gnu.org Received: via spool by 69133-submit@debbugs.gnu.org id=B69133.17079772688178 (code B ref 69133); Thu, 15 Feb 2024 06:08:01 +0000 Received: (at 69133) by debbugs.gnu.org; 15 Feb 2024 06:07:48 +0000 Received: from localhost ([127.0.0.1]:53737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raUuR-00027q-Tv for submit@debbugs.gnu.org; Thu, 15 Feb 2024 01:07:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48044) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raUuP-00027c-9e for 69133@debbugs.gnu.org; Thu, 15 Feb 2024 01:07:46 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raUu1-0001dR-1F; Thu, 15 Feb 2024 01:07:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=XJ7ieIiNH9Cdh1CW3n82mKivG+Q8Dz1//Rp1qLUysh0=; b=Y8NvWiuUR2SiTF+AdHu0 zvjxZfSP77HfDGUse0KYhSEQGS8RYHFUG7mhh0n7nZmbD3OZySlwTm2hGBFd/b6oHG68h+KmaaUof M/g/brpL1vOidhySzIGmhW945yj1s/QK+J6J1lP92PNWXC/bih0t6pVB6dxUsh7TU+VJB40OlL3+u 0An3WHx3182eo8VQ5B+tzyq7ZLxkKHtBcZ7JtIuzdGQSJlB8sgEcgl4u+8d3gQVGCXR0qzNRrYrg1 NOSbENm5dub31MbiecWMYuWi6bhMrP+4d9lb+wn1F64DatI78NPoG5Smucd4iAeQvuL2p7kZ5gxXT 7Vngea8KdKLfKA==; Date: Thu, 15 Feb 2024 08:07:17 +0200 Message-Id: <8634tuxnu2.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <875xyqbzgj.fsf@disroot.org> (bug-gnu-emacs@gnu.org) References: <875xyqbzgj.fsf@disroot.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.2 (-----) > Date: Wed, 14 Feb 2024 22:47:08 +0300 > From: Aleksandr Vityazev via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > 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? Thanks, some comments below, > --- 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' Heading lines in NEWS should end with a period. > +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. This sentence is too complex. Suggest to reword as two sentences: This allows the user to customize the key selection method, which can be either by using a pop-up buffer or from the minibuffer. The pop-up buffer method is the default, which preserves previous behavior. Also, why did you decide not to document this in the manual? epa.el has its own manual, so how about adding this option to it? > +(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." The doc string could also be simplified. Like this, for example: Method used to select keys in `epa-select-keys'. If the value is \\='buffer, the default, keys are selected via a pop-up buffer. If the value is \\='minibuffer, keys are selected via the minibuffer instead, using `completing-read-multiple'. This avoids explaining the values twice (first what they are, then what they do), and also mentions the default value. Please also make sure comments, doc strings, and commit log messages leave two spaces between sentences, per our conventions. You had a couple of problems with that in the patch, which my suggested rephrasing fixed, but please keep this in mind in the future. > + :type '(choice (const :tag "Read keys from buffer" buffer) ^^^^^^^^^^^^^^^^^^^^^ This should probably say "...from a pop-up buffer". > (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"))))) Hmm... are you assuming users know how to input multiple strings from the minibuffer, in particular what is the value of crm-separator? the function epa--select-keys inserts some instructions into the pop-up buffer, but this new function you propose just shows the prompt and nothing else. Should it somehow help the user with the job of typing the keys at the prompt? Also, maybe instead of signaling an error for a value that's neither 'buffer' nor 'minibuffer', we should treat such values as 'buffer'? From unknown Mon Jun 23 02:26:34 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69133: [PATCH] Make key selection method configurable in EPA. Resent-From: Aleksandr Vityazev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Feb 2024 20:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 69133@debbugs.gnu.org Received: via spool by 69133-submit@debbugs.gnu.org id=B69133.170802857726838 (code B ref 69133); Thu, 15 Feb 2024 20:23:01 +0000 Received: (at 69133) by debbugs.gnu.org; 15 Feb 2024 20:22:57 +0000 Received: from localhost ([127.0.0.1]:57186 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raiG0-0006yn-Fx for submit@debbugs.gnu.org; Thu, 15 Feb 2024 15:22:57 -0500 Received: from layka.disroot.org ([178.21.23.139]:34586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raiFx-0006yb-CU for 69133@debbugs.gnu.org; Thu, 15 Feb 2024 15:22:54 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 457B040E31; Thu, 15 Feb 2024 21:22:33 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IIWM70DgHErh; Thu, 15 Feb 2024 21:22:32 +0100 (CET) From: Aleksandr Vityazev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1708028552; bh=2Mcs7xwjHiGFqWnQvEP2gpnRP/j4NL0S5QEWQDjDScI=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=PJNPL1244u4+BmGWLLW8j+gG2+Z2Pa3rsNbm6zYNFk97y/N4l18lnjFIKxJjdAtGo h24TQfikeLR8Zxd14lq+VDjOIl7+LuWyxx226ueBc7qMmXZrxqXT+1ts7Cj323Op+i nSiDqk0aueeEvYJTCDcVSRf8ZCaT5zFDCHGGf2XYn1BKQCXay48vt/FbohIt18MADu 2ip3ia7STUlCcbuGB8zQGKgZRsOgoZfYEyYbWeyo8j6nQznjAFy10R444dv8b1889Q mAS64g3dhecYB1SggkE+zgNbZuUXyqT4mjiPcUYcV3yYfJIjHjPRVXZNeeyPmoKBFw w3TSsjZqS2eLA== In-Reply-To: <8634tuxnu2.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 15 Feb 2024 08:07:17 +0200") References: <875xyqbzgj.fsf@disroot.org> <8634tuxnu2.fsf@gnu.org> Date: Thu, 15 Feb 2024 23:22:29 +0300 Message-ID: <87o7chbhq2.fsf@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.9 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks, added the fixes, attached the version 2 patch On 2024-02-15 08:07, Eli Zaretskii wrote: >> Date: Wed, 14 Feb 2024 22:47:08 +0300 >> From: Aleksandr Vityazev via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >>=20 >> 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? > > Thanks, some comments below, > >> --- a/etc/NEWS >> +++ b/etc/NEWS >> @@ -1352,6 +1352,14 @@ characters, such as =C2=BD (U+00BD VULGAR FRACTIO= N 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. >>=20 >> +** EasyPG >> + >> +--- >> +*** New user option 'epa-keys-select-method' > > Heading lines in NEWS should end with a period. > Fixed >> +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. > > This sentence is too complex. Suggest to reword as two sentences: > > This allows the user to customize the key selection method, which > can be either by using a pop-up buffer or from the minibuffer. The > pop-up buffer method is the default, which preserves previous > behavior. > Applied > Also, why did you decide not to document this in the manual? epa.el > has its own manual, so how about adding this option to it? Added > >> +(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." > > The doc string could also be simplified. Like this, for example: > > Method used to select keys in `epa-select-keys'. > If the value is \\=3D'buffer, the default, keys are selected via a > pop-up buffer. If the value is \\=3D'minibuffer, keys are selected > via the minibuffer instead, using `completing-read-multiple'. > Applied > This avoids explaining the values twice (first what they are, then > what they do), and also mentions the default value. > > Please also make sure comments, doc strings, and commit log messages > leave two spaces between sentences, per our conventions. You had a > couple of problems with that in the patch, which my suggested > rephrasing fixed, but please keep this in mind in the future. > >> + :type '(choice (const :tag "Read keys from buffer" buffer) > ^^^^^^^^^^^^^^^^^^^^^ > This should probably say "...from a pop-up buffer". Fixed > >> (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"))))) > > Hmm... are you assuming users know how to input multiple strings from > the minibuffer, in particular what is the value of crm-separator? the > function epa--select-keys inserts some instructions into the pop-up > buffer, but this new function you propose just shows the prompt and > nothing else. Should it somehow help the user with the job of typing > the keys at the prompt? The crm-separator is "[ \t]*,[ \t]*", so I added a "(comma separated)" hint that will be in all prompts. > > Also, maybe instead of signaling an error for a value that's neither > 'buffer' nor 'minibuffer', we should treat such values as 'buffer'? Agree, fixed --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Make-key-selection-method-configurable-in-EPA.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch-v2 >From 479c4ca5c8c97b5b9a8b64a0ba7fdbdc0f5ae299 Mon Sep 17 00:00:00 2001 Message-ID: <479c4ca5c8c97b5b9a8b64a0ba7fdbdc0f5ae299.1708026698.git.avitya= zev@disroot.org> From: Aleksandr Vityazev Date: Thu, 15 Feb 2024 22:51:24 +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: Announce it. * doc/misc/epa.texi (Key Management): Document it. --- doc/misc/epa.texi | 7 +++++++ etc/NEWS | 8 ++++++++ lisp/epa.el | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/doc/misc/epa.texi b/doc/misc/epa.texi index 27a9e2b0ebb..cd6da1dadba 100644 --- a/doc/misc/epa.texi +++ b/doc/misc/epa.texi @@ -289,6 +289,13 @@ Cryptographic operations on regions you answered yes, it will let you select the signing keys. @end deffn +You can change the default method that is used to select keys with the +variable @code{epa-file-select-keys}. + +@defvar epa-keys-select-method +Method used to select keys in @code{epa-select-keys}. +@end defvar + @node Cryptographic operations on files @section Cryptographic Operations on Files @cindex cryptographic operations on files diff --git a/etc/NEWS b/etc/NEWS index e6b1d424499..ba609680c24 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1352,6 +1352,14 @@ characters, such as =C2=BD (U+00BD VULGAR FRACTION O= NE 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, which can be +either by using a pop-up buffer or from the minibuffer. The pop-up +buffer method is the default, which preserves previous behavior. + * New Modes and Packages in Emacs 30.1 diff --git a/lisp/epa.el b/lisp/epa.el index 53da3bf6cce..b2593bc62ba 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -73,6 +73,16 @@ epa-mail-aliases :group 'epa :version "24.4") +(defcustom epa-keys-select-method 'buffer + "Method used to select keys in `epa-select-keys'. +If the value is \\=3D'buffer, the default, keys are selected via a +pop-up buffer. If the value is \\=3D'minibuffer, keys are selected +via the minibuffer instead, using `completing-read-multiple'." + :type '(choice (const :tag "Read keys from a pop-up buffer" buffer) + (const :tag "Read keys from minibuffer" minibuffer)) + :group 'epa + :version "30.1") + ;;; Faces (defgroup epa-faces nil @@ -450,6 +460,25 @@ epa--select-keys (epa--marked-keys)) (kill-buffer epa-keys-buffer))))) +(defun epa--select-keys-in-minibuffer (prompt keys) + (let* ((prompt (pcase-let ((`(,first ,second ,third) + (string-split prompt "\\.")) + (hint "(separated by comma)")) + (if third + (format "%s %s. %s: " first hint second) + (format "%s %s: " first hint)))) + (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,6 +488,8 @@ 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 + ('minibuffer (epa--select-keys-in-minibuffer prompt keys)) + (_ (epa--select-keys prompt keys))))) ;;;; Key Details -- 2.41.0 --=-=-= Content-Type: text/plain -- Best regards, Aleksandr Vityazev --=-=-=-- From unknown Mon Jun 23 02:26:34 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Aleksandr Vityazev Subject: bug#69133: closed (Re: bug#69133: [PATCH] Make key selection method configurable in EPA.) Message-ID: References: <861q9bv3kn.fsf@gnu.org> <875xyqbzgj.fsf@disroot.org> X-Gnu-PR-Message: they-closed 69133 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 69133@debbugs.gnu.org Date: Sat, 17 Feb 2024 09:33:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1708162382-30060-1" This is a multi-part message in MIME format... ------------=_1708162382-30060-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #69133: [PATCH] Make key selection method configurable in EPA. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 69133@debbugs.gnu.org. --=20 69133: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D69133 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1708162382-30060-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 69133-done) by debbugs.gnu.org; 17 Feb 2024 09:33:00 +0000 Received: from localhost ([127.0.0.1]:60461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbH48-0007oc-GB for submit@debbugs.gnu.org; Sat, 17 Feb 2024 04:33:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbH43-0007oL-TL for 69133-done@debbugs.gnu.org; Sat, 17 Feb 2024 04:32:58 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbH3c-0000gp-PW; Sat, 17 Feb 2024 04:32:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=obUfb7nylXF+BhmB6H2BrdddYzII6RfmD+y/JRJzdCs=; b=e2h93Y/fo1Gj LM3J8NJVkoniahUAgCgIy4TWWF58LzOF+2qZua9EeQ/muMMmhTMkEEVteCS/QaRkwE1M1anWfsrPE QUnVFH/6MMM3ewLeFgXnooARo7Xq8ripPPHFOd7D3ULKZl2UMN/ntX3me8de4QtdYZzHr9ZZSKhgw di+RS52ZAqEkbtfI/jEK9JR1D0SaJLqgBTxmmKHE0TYVNgbGrZ72HJGM1VAgnipdnbnFRJUIhAmkn 8zIGEfJ8WPSsJceLlGsaWScjnKCuVo2KZtEEkCAzTbzBBqhlwkRtBJpc1xAicZ5wY2hWdt+Pxw/tL bD2w8B+XFSl4sO48H8jSKw==; Date: Sat, 17 Feb 2024 11:32:24 +0200 Message-Id: <861q9bv3kn.fsf@gnu.org> From: Eli Zaretskii To: Aleksandr Vityazev In-Reply-To: <87o7chbhq2.fsf@disroot.org> (message from Aleksandr Vityazev on Thu, 15 Feb 2024 23:22:29 +0300) Subject: Re: bug#69133: [PATCH] Make key selection method configurable in EPA. References: <875xyqbzgj.fsf@disroot.org> <8634tuxnu2.fsf@gnu.org> <87o7chbhq2.fsf@disroot.org> X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 69133-done Cc: 69133-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.2 (-----) > From: Aleksandr Vityazev > Cc: 69133@debbugs.gnu.org > Date: Thu, 15 Feb 2024 23:22:29 +0300 > > Thanks, added the fixes, attached the version 2 patch Thanks, installed on master, and closing the bug. ------------=_1708162382-30060-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Feb 2024 19:47:43 +0000 Received: from localhost ([127.0.0.1]:53162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raLEN-0001ak-CL for submit@debbugs.gnu.org; Wed, 14 Feb 2024 14:47:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:35840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raLEL-0001ac-JZ for submit@debbugs.gnu.org; Wed, 14 Feb 2024 14:47:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raLE3-0000EW-3X for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:47:23 -0500 Received: from layka.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raLE0-0000sU-Mv for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:47:22 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6D4D544DFC for ; Wed, 14 Feb 2024 20:47:17 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FWfZh5z_kWQE for ; Wed, 14 Feb 2024 20:47:16 +0100 (CET) From: Aleksandr Vityazev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1707940036; bh=D3OwXG5ljeRR5YPjEJKZjW1gfKnMfo9+q+bnO6jEdOQ=; h=From:To:Subject:Date; b=eP31X3ct72WDLyegWU67/lGSlkARKybS2wVo2Hj9f9PlMh658YgAp7CDuw0PBRzqU dVq7/fG+CDBqsU9GZtSzYT04xenL+OuGafdoAxmLlpjB370cPVv4zqJHCWsdj8rJLZ Fyx5Lws0Y229woHXHV+2EBoIJlIjzS6lhleEpRMubOVrphrHCe6YFPiRFiZVOcyCTP YQFHpgR3nsK7qTSjYTbFVP3srB5siq6tdS8ctPjY9C4Qh1xahIrhMyJEzq+ohGbRjU mbMzjjimtgl5cdjmgIWWUsZcwWkrhpZpe5DUP8wL9lLDe/eCIDGSuXo+e51oLL8N4O ykxMyuHShMHsw== To: bug-gnu-emacs@gnu.org Subject: [PATCH] Make key selection method configurable in EPA. Date: Wed, 14 Feb 2024 22:47:08 +0300 Message-ID: <875xyqbzgj.fsf@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=178.21.23.139; envelope-from=avityazev@disroot.org; helo=layka.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.2 (-----) --=-=-= Content-Type: text/plain 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? --=-=-= Content-Type: text/patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Make-key-selection-method-configurable-in-EPA.patch Content-Transfer-Encoding: quoted-printable >From 95e277514bc7b92858b92dacca66683dd31e6da2 Mon Sep 17 00:00:00 2001 Message-ID: <95e277514bc7b92858b92dacca66683dd31e6da2.1707939800.git.avitya= zev@disroot.org> From: Aleksandr Vityazev 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 =C2=BD (U+00BD VULGAR FRACTION O= NE 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. + * 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 --=-=-= Content-Type: text/plain -- Best regards, Aleksandr Vityazev --=-=-=-- ------------=_1708162382-30060-1--