unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Tomotaka SUWA <tomotaka.suwa@gmail.com>
Cc: 42029@debbugs.gnu.org
Subject: bug#42029: `gnus-registry-spool-action' gets field beyond message headers
Date: Fri, 26 Jun 2020 11:32:19 -0700	[thread overview]
Message-ID: <87mu4pu18s.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <CABiafbVHQO46qM4DB+qaCssxZvCdDcheRgEoR6kuuufAXZCing@mail.gmail.com> (Tomotaka SUWA's message of "Thu, 25 Jun 2020 09:52:43 +0900")

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]

Tomotaka SUWA <tomotaka.suwa@gmail.com> writes:

>> Thanks for this report. It might be simpler to wrap the whole thing in a
>> single save-restriction+narrow-to-headers, since the function gets
>> called four times. What do you think?
>
> I wrote the patch paying attention to minimize side effects since I'm not
> familiar with that functionality. So if `gnus-registry-spool-action' is
> interested in only mail headers, your proposal is much better.

Okay! Would you be willing to give the attached diff a quick test?

Thanks,
Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: protect-registry-spool-action.diff --]
[-- Type: text/x-patch, Size: 2354 bytes --]

diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index f306889a7f..a36095c1ec 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -449,19 +449,21 @@ gnus-registry-action
      to subject sender recipients)))
 
 (defun gnus-registry-spool-action (id group &optional subject sender recipients)
-  (let ((to (gnus-group-guess-full-name-from-command-method group))
-        (recipients (or recipients
-                        (gnus-registry-sort-addresses
-                         (or (message-fetch-field "cc") "")
-                         (or (message-fetch-field "to") ""))))
-        (subject (or subject (message-fetch-field "subject")))
-        (sender (or sender (message-fetch-field "from"))))
-    (when (and (stringp id) (string-match "\r$" id))
-      (setq id (substring id 0 -1)))
-    (gnus-message 7 "Gnus registry: article %s spooled to %s"
-                  id
-                  to)
-    (gnus-registry-handle-action id nil to subject sender recipients)))
+  (save-excursion
+    (message-narrow-to-headers-or-head)
+    (let ((to (gnus-group-guess-full-name-from-command-method group))
+          (recipients (or recipients
+                          (gnus-registry-sort-addresses
+                           (or (message-fetch-field "cc") "")
+                           (or (message-fetch-field "to") ""))))
+          (subject (or subject (message-fetch-field "subject")))
+          (sender (or sender (message-fetch-field "from"))))
+      (when (and (stringp id) (string-match "\r$" id))
+	(setq id (substring id 0 -1)))
+      (gnus-message 7 "Gnus registry: article %s spooled to %s"
+                    id
+                    to)
+      (gnus-registry-handle-action id nil to subject sender recipients))))
 
 (defun gnus-registry-handle-action (id from to subject sender
                                        &optional recipients)
@@ -1064,7 +1066,7 @@ gnus-registry-get-article-marks
 Uses process/prefix conventions.  For multiple articles,
 only the last one's marks are returned."
   (interactive (gnus-summary-work-articles 1))
-  (let* ((article (last articles))
+  (let* ((article (car (last articles)))
          (id (gnus-registry-fetch-message-id-fast article))
          (marks (when id (gnus-registry-get-id-key id 'mark))))
     (when (called-interactively-p 'any)

  reply	other threads:[~2020-06-26 18:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 11:49 bug#42029: `gnus-registry-spool-action' gets field beyond message headers tomotaka.suwa
2020-06-24 17:25 ` Eric Abrahamsen
2020-06-25  0:52   ` Tomotaka SUWA
2020-06-26 18:32     ` Eric Abrahamsen [this message]
2020-06-26 21:24       ` Basil L. Contovounesios
2020-06-26 22:01         ` Eric Abrahamsen
2020-06-29  2:26       ` Tomotaka SUWA
2020-07-19  0:20         ` Lars Ingebrigtsen
2020-07-19  3:05           ` Eric Abrahamsen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mu4pu18s.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=42029@debbugs.gnu.org \
    --cc=tomotaka.suwa@gmail.com \
    /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 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).