From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aleksandr Vityazev via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69133: [PATCH] Make key selection method configurable in EPA. Date: Wed, 14 Feb 2024 22:47:08 +0300 Message-ID: <875xyqbzgj.fsf@disroot.org> Reply-To: Aleksandr Vityazev Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6127"; mail-complaints-to="usenet@ciao.gmane.io" To: 69133@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 14 20:47:59 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raLEd-0001Lv-J6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Feb 2024 20:47:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raLES-0000Gv-Nj; Wed, 14 Feb 2024 14:47:48 -0500 Original-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 1raLEO-0000GQ-M9 for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:47:44 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raLEO-0000wZ-Dv for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:47:44 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1raLEg-0001bJ-Iw for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 14:48:02 -0500 X-Loop: help-debbugs@gnu.org 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 X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17079400636126 (code B ref -1); Wed, 14 Feb 2024 19:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Feb 2024 19:47:43 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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) 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== 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280027 Archived-At: --=-=-= 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 --=-=-=--