Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
Cc: ding@gnus.org
Subject: Re: saving copies of the messages sent in Gnus
Date: Fri, 25 Nov 2011 13:26:44 +0900	[thread overview]
Message-ID: <b4m4nxsx1x6.fsf@jpl.org> (raw)
In-Reply-To: <86aa82vwg4.fsf@gray.siamics.net>

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

Cc: ding <at> gnus.org
Topic: gnus-summary-resend-message doesn't do Gcc

Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>> Katsumi Yamaoka <yamaoka@jpl.org> writes:
>> ...whereas a message to resend is never modified and is already
>> in some group.  Even if it is Gcc'd, Resent- headers don't appear
>> in the article buffer normally.  So, Gcc'ing it does only eat
>> disk, as especially to gcc-self, I think.

> Resent-From: is mentioned in the default gnus-visible-headers,
> not to mention that the latter is trivial to expand to cover any
> of the other headers just as well.

I forgot having excluded Resent headers from my `gnus-visible-headers',
sorry.

> However, my point is that I wish to be able to check my postings
> /as they were sent/.  Certain software, such as some mailing
> lists packages, and the like, are known to (occasionally) mangle
> message's header, body, or both.  There, having a local copy of
> the message sent could be quite a debugging aid.

Gcc to a `sent' group might be useful, I thought afterward.  So,
I tried making `gnus-summary-resend-message' do Gcc.  The new
user option `gnus-gcc-inhibit-gcc-self-when-resending' controls
whether to archive resent articles in the identical group or not.
The default value is t, i.e. inhibit.  A patch is below.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3464 bytes --]

2011-11-25  Katsumi Yamaoka  <yamaoka@jpl.org>

	* gnus-msg.el (gnus-gcc-inhibit-gcc-self-when-resending): New option.
	(gnus-summary-resend-messag): Modify message-header-setup-hook and
	message-sent-hook to make it work for Gcc.

	* message.el (message-resend): Run message-sent-hook to do Gcc.

--- gnus-msg.el~	2011-09-11 22:00:39 +0000
+++ gnus-msg.el	2011-11-25 04:22:24 +0000
@@ -163,6 +163,14 @@
 		 (const all :tag "Any")
 		 (string :tag "Regexp")))
 
+(defcustom gnus-gcc-inhibit-gcc-self-when-resending t
+  "If non-nil, don't do Gcc to the identical group when resending articles.
+This variable is effective when resending articles with no modification
+using `gnus-summary-resend-message'."
+  :version "24.2"
+  :group 'gnus-message
+  :type 'boolean)
+
 (gnus-define-group-parameter
  posting-charset-alist
  :type list
@@ -1277,12 +1285,30 @@
 	    (with-current-buffer gnus-original-article-buffer
 	      (nnmail-fetch-field "to"))))
 	 current-prefix-arg))
-  (dolist (article (gnus-summary-work-articles n))
-    (gnus-summary-select-article nil nil nil article)
-    (with-current-buffer gnus-original-article-buffer
-      (let ((gnus-gcc-externalize-attachments nil))
-	(message-resend address)))
-    (gnus-summary-mark-article-as-forwarded article)))
+  (let ((message-header-setup-hook (copy-sequence message-header-setup-hook))
+	(message-sent-hook (copy-sequence message-sent-hook)))
+    (add-hook 'message-header-setup-hook
+	      (lambda nil
+		(gnus-inews-insert-gcc)
+		(when gnus-gcc-inhibit-gcc-self-when-resending
+		  (let ((gcc (mail-fetch-field "gcc" nil t)))
+		    (when gcc
+		      (message-remove-header "gcc")
+		      (when (setq gcc (delete
+				       gnus-newsgroup-name
+				       (message-unquote-tokens
+					(message-tokenize-header gcc " ,"))))
+			(insert "Gcc: "
+				(mapconcat 'identity gcc ", ") "\n")))))))
+    (add-hook 'message-sent-hook (if gnus-agent
+				     'gnus-agent-possibly-do-gcc
+				   'gnus-inews-do-gcc))
+    (dolist (article (gnus-summary-work-articles n))
+      (gnus-summary-select-article nil nil nil article)
+      (with-current-buffer gnus-original-article-buffer
+	(let ((gnus-gcc-externalize-attachments nil))
+	  (message-resend address)))
+      (gnus-summary-mark-article-as-forwarded article))))
 
 ;; From: Matthieu Moy <Matthieu.Moy@imag.fr>
 (defun gnus-summary-resend-message-edit ()
--- message.el~	2011-11-20 22:02:20 +0000
+++ message.el	2011-11-25 04:22:24 +0000
@@ -7562,7 +7562,7 @@
   (message "Resending message to %s..." address)
   (save-excursion
     (let ((cur (current-buffer))
-	  beg)
+	  gcc beg)
       ;; We first set up a normal mail buffer.
       (unless (message-mail-user-agent)
 	(set-buffer (get-buffer-create " *message resend*"))
@@ -7575,6 +7575,8 @@
       ;; Insert our usual headers.
       (message-generate-headers '(From Date To Message-ID))
       (message-narrow-to-headers)
+      (when (setq gcc (mail-fetch-field "gcc" nil t))
+	(message-remove-header "gcc"))
       ;; Remove X-Draft-From header etc.
       (message-remove-header message-ignored-mail-headers t)
       ;; Rename them all to "Resent-*".
@@ -7616,6 +7618,10 @@
 	    message-generate-hashcash
 	    rfc2047-encode-encoded-words)
 	(message-send-mail))
+      (when gcc
+	(message-goto-eoh)
+	(insert "Gcc: " gcc "\n"))
+      (run-hooks 'message-sent-hook)
       (kill-buffer (current-buffer)))
     (message "Resending message to %s...done" address)))
 

       reply	other threads:[~2011-11-25  4:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87sjlw9c9d.fsf@violet.siamics.net>
     [not found] ` <87r51fvytj.fsf@marauder.physik.uni-ulm.de>
     [not found]   ` <b4m7h36lx6n.fsf@jpl.org>
     [not found]     ` <86aa82vwg4.fsf@gray.siamics.net>
2011-11-25  4:26       ` Katsumi Yamaoka [this message]
2012-01-03 21:37         ` Lars Magne Ingebrigtsen
2012-01-05  7:28           ` Katsumi Yamaoka
2012-01-05 10:43             ` Steinar Bang
2012-01-09 19:40               ` Steinar Bang
2012-02-02  1:27             ` Katsumi Yamaoka
2012-01-07  2:04           ` Ted Zlatanov
2012-01-07  6:21             ` Lars Magne Ingebrigtsen
2012-01-07 13:03               ` Ted Zlatanov

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=b4m4nxsx1x6.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).