* bug#39964: [PATCH] Add support for creating OpenPGP header
@ 2020-03-07 0:11 Philip K
2020-03-07 7:53 ` Eli Zaretskii
2020-08-08 13:50 ` Lars Ingebrigtsen
0 siblings, 2 replies; 3+ messages in thread
From: Philip K @ 2020-03-07 0:11 UTC (permalink / raw)
To: 39964; +Cc: Philip K
From: Philip K <philip.kaludercic@fau.de>
See [0] for more details on it's usage and interpretation.
[0]: https://tools.ietf.org/html/draft-josefsson-openpgp-mailnews-header
---
lisp/gnus/message.el | 57 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index adefa0efd6..1c9c99afbe 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -2730,6 +2730,63 @@ message-sign-encrypt-if-all-keys-available
(when (message-all-epg-keys-available-p)
(mml-secure-message-sign-encrypt)))
+(defcustom message-openpgp-header nil
+ "Specification for \"OpenPGP\" header.
+
+Otherwise, the variable must be a
+list with three elements, all strings:
+- Key ID, in hexadecimal form
+- Key URL or ASCII armoured key.
+- Protection preference, one of: \"unprotected\", \"sign\",
+ \"encrypt\" or \"signencrypt\".
+
+Each value may be nil, in which case it won't be inserted. If all
+the values are nil, or `message-openpgp-header' is nil itself,
+don't insert any header."
+ :type '(choice
+ (const nil :tag "Don't add OpenPGP header")
+ (list (choice (string :tag "ID")
+ (const nil :tag "No ID"))
+ (choice (string :tag "Key")
+ (const nil :tag "No Key"))
+ (choice (other nil :tag "None")
+ (const "unprotected" :tag "Unprotected")
+ (const "sign" :tag "Sign")
+ (const "encrypt" :tag "Encrypt")
+ (const "signencrypt" :tag "Sign and Encrypt")))))
+
+(defun messasge-add-openpgp-header ()
+ "Add OpenPGP header to point to public key.
+
+Header will be constructed as specified in `message-openpgp-header'.
+
+Consider adding this function to `message-send-hook'."
+ ;; See https://tools.ietf.org/html/draft-josefsson-openpgp-mailnews-header
+ (when (and message-openpgp-header
+ (or (nth 0 message-openpgp-header)
+ (nth 1 message-openpgp-header)
+ (nth 2 message-openpgp-header)))
+ (with-temp-buffer
+ (insert "OpenPGP: ")
+ ;; add ID
+ (let (need-sep)
+ (when (nth 0 message-openpgp-header)
+ (insert "id=" (nth 0 message-openpgp-header))
+ (setq need-sep t))
+ ;; add URL
+ (when (nth 1 message-openpgp-header)
+ (when need-sep (insert "; "))
+ (if (string-match-p ";")
+ (insert "url=\"" (nth 1 message-openpgp-header) "\"")
+ (insert "url=\"" (nth 1 message-openpgp-header) "\""))
+ (setq need-sep t))
+ ;; add preference
+ (when (nth 2 message-openpgp-header)
+ (when need-sep (insert "; "))
+ (insert "preference=" (nth 2 message-openpgp-header))))
+ ;; insert header
+ (message-add-header (buffer-string)))))
+
\f
;;;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#39964: [PATCH] Add support for creating OpenPGP header
2020-03-07 0:11 bug#39964: [PATCH] Add support for creating OpenPGP header Philip K
@ 2020-03-07 7:53 ` Eli Zaretskii
2020-08-08 13:50 ` Lars Ingebrigtsen
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2020-03-07 7:53 UTC (permalink / raw)
To: Philip K; +Cc: philip.kaludercic, 39964
> From: Philip K <philip@warpmail.net>
> Date: Sat, 7 Mar 2020 01:11:28 +0100
> Cc: Philip K <philip.kaludercic@fau.de>
>
> +(defcustom message-openpgp-header nil
> + "Specification for \"OpenPGP\" header.
This defcustom lacks the :version tag.
Also, please always accompany user-visible changes with a suitable
NEWS entry and changes for the relevant Info manual.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#39964: [PATCH] Add support for creating OpenPGP header
2020-03-07 0:11 bug#39964: [PATCH] Add support for creating OpenPGP header Philip K
2020-03-07 7:53 ` Eli Zaretskii
@ 2020-08-08 13:50 ` Lars Ingebrigtsen
1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-08 13:50 UTC (permalink / raw)
To: Philip K; +Cc: Philip K, 39964
Philip K <philip@warpmail.net> writes:
> From: Philip K <philip.kaludercic@fau.de>
>
> See [0] for more details on it's usage and interpretation.
>
> [0]: https://tools.ietf.org/html/draft-josefsson-openpgp-mailnews-header
[...]
> +(defcustom message-openpgp-header nil
> + "Specification for \"OpenPGP\" header.
Thanks; I've applied your patch to Emacs 28 (along with additions
suggested by Eli).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-08 13:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07 0:11 bug#39964: [PATCH] Add support for creating OpenPGP header Philip K
2020-03-07 7:53 ` Eli Zaretskii
2020-08-08 13:50 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).