From: "Philip K." <philipk@posteo.net>
To: 42913@debbugs.gnu.org
Subject: bug#42913: [PATCH] Fix issues with OpenPGP header
Date: Tue, 18 Aug 2020 15:21:53 +0200 [thread overview]
Message-ID: <87tux0qeby.fsf@posteo.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 318 bytes --]
Hi,
I submitted a patch a few months ago, to generate OpenPGP headers, that
seems like it was a bit faulty. When trying it out today, it didn't seem
to work properly, so I debugged it and made a few changes attached
below.
My appologies for not testing the patch thoroughly enough. I hope
everything is fixed now.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-issues-with-OpenPGP-header.patch --]
[-- Type: text/x-patch, Size: 3964 bytes --]
From 1053988e26dd614aeb4490ae853d2c1c502cc493 Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Tue, 18 Aug 2020 15:12:51 +0200
Subject: [PATCH] Fix issues with OpenPGP header
* doc/misc/message.texi (OpenPGP Header): Mention correct hook
* lisp/gnus/message.el (message-openpgp-header): Improve customize type
(message-add-openpgp-header): Insert header into correct buffer
---
doc/misc/message.texi | 2 +-
lisp/gnus/message.el | 63 ++++++++++++++++++++++---------------------
2 files changed, 34 insertions(+), 31 deletions(-)
diff --git a/doc/misc/message.texi b/doc/misc/message.texi
index 204a6386e0..55b166eb8b 100644
--- a/doc/misc/message.texi
+++ b/doc/misc/message.texi
@@ -1265,7 +1265,7 @@ OpenPGP Header
To use this in Message, say:
@lisp
-(add-hook 'message-send-hook 'message-add-openpgp-header)
+(add-hook 'message-header-setup-hook 'message-add-openpgp-header)
@end lisp
@noindent
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index ab625be9e3..07ff489038 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -2751,16 +2751,17 @@ message-openpgp-header
or `message-openpgp-header' is itself nil, the OpenPGP header
will not be inserted."
:type '(choice
- (const nil :tag "Don't add OpenPGP header")
- (list (choice (string :tag "ID")
- (const nil :tag "No ID"))
+ (const :tag "Don't add OpenPGP header" nil)
+ (list :tag "Use OpenPGP header"
+ (choice (string :tag "ID")
+ (const :tag "No ID" nil))
(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"))))
+ (const :tag "No Key" nil))
+ (choice (other :tag "None" nil)
+ (const :tag "Unprotected" "unprotected")
+ (const :tag "Sign" "sign")
+ (const :tag "Encrypt" "encrypt")
+ (const :tag "Sign and Encrypt" "signencrypt"))))
:version "28.1")
(defun message-add-openpgp-header ()
@@ -2768,32 +2769,34 @@ message-add-openpgp-header
Header will be constructed as specified in `message-openpgp-header'.
-Consider adding this function to `message-send-hook'."
+Consider adding this function to `message-header-setup-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)))))
+ (message-add-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
+ (buffer-string)))
+ (message-sort-headers)))
\f
--
2.26.2
next reply other threads:[~2020-08-18 13:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 13:21 Philip K. [this message]
2020-08-18 16:06 ` bug#42913: [PATCH] Fix issues with OpenPGP header Lars Ingebrigtsen
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=87tux0qeby.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=42913@debbugs.gnu.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.