unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42913: [PATCH] Fix issues with OpenPGP header
@ 2020-08-18 13:21 Philip K.
  2020-08-18 16:06 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Philip K. @ 2020-08-18 13:21 UTC (permalink / raw)
  To: 42913

[-- 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#42913: [PATCH] Fix issues with OpenPGP header
  2020-08-18 13:21 bug#42913: [PATCH] Fix issues with OpenPGP header Philip K.
@ 2020-08-18 16:06 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-18 16:06 UTC (permalink / raw)
  To: Philip K.; +Cc: 42913

"Philip K." <philipk@posteo.net> writes:

> 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.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-18 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 13:21 bug#42913: [PATCH] Fix issues with OpenPGP header Philip K.
2020-08-18 16:06 ` 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).