Gnus development mailing list
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Re: send reply email from gnus and archive original
Date: Thu, 19 Jun 2014 16:36:24 -0700	[thread overview]
Message-ID: <874mzgzd3b.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <m361jxf32c.fsf@jkitchin-780.cheme.cmu.edu>

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> Hi everyone,
>
> I am trying to switch from the web interface of gmail to gnus. I have
> succeeded in getting gnus to read my mail!
>
> ("nnimap gmail:INBOX")
>
> A feature of the web interface I really liked was the ability to reply
> to an email, and upon sending it, archive the original email. Is there a
> way to do that in gnus? Using a hook or something? Basically I want to
> move the replied to email from the INBOX to the [Gmail]/All Mail folder
> after I repply to it.
>
> Thanks!

I guess I'd recommend using the message-sent-hook: that way you know the
message has successfully sent, but you're still in the message buffer.

In the message buffer, you can get the X-Draft-From header, which tells
you how to find the message you're replying to (there's also the
message-reply-headers variable, but that doesn't have the group
information). Then you can ask gnus to move the article. My guess is you
could call `nnimap-request-move-article' directly, but it would probably
be safer to visit the original in its summary buffer and then use
`gnus-summary-move-article'. The following is very, very lightly tested:

(defun archive-original-gmail (&optional to-group)
  (save-window-excursion
    (save-restriction
     (message-narrow-to-headers-or-head)
     (let ((draft-from (read (message-fetch-field "X-Draft-From")))
	   group article-number)
       (when draft-from
	 (setq group (car draft-from)
	       article-number (cadr draft-from))
	 (gnus-activate-group group)
	 (when (member (cadr (gnus-find-method-for-group group))
                        ;; only activate for some servers
		       '("Applicable" "Server" "Names"))
	   (gnus-group-read-group t nil group
				  (list article-number))
	   (gnus-summary-move-article nil "\[Gmail\]/All Mail")))))))

You'd put that in the message-sent-hook. I'd love to hear if anyone had
a better solution!

E




  reply	other threads:[~2014-06-19 23:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 13:20 John Kitchin
2014-06-19 23:36 ` Eric Abrahamsen [this message]
2014-09-24 21:00 ` Ted Zlatanov
2014-09-25  7:42 ` Steinar Bang

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=874mzgzd3b.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --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).