emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ulf Stegemann <ulf-news@zeitform.de>
To: emacs-orgmode@gnu.org
Subject: Re: Store link upon sending a message
Date: Fri, 12 Nov 2010 14:03:41 +0100	[thread overview]
Message-ID: <zf.upn7hgizob6.fsf@zeitform.de> (raw)
In-Reply-To: zf.upnbp7egp0e.fsf@zeitform.de

I came back to the matter of storing an org link to a copy of a message
upon sending that message.  The function below does just that and proves
to be quite useful together with a sensible key binding (if you use Gnus
and Gcc that is).

--8<------------------cut here----------------start---------------->8---

(defun ulf-message-send-and-org-gnus-store-link (&optional arg)
  "Send message with `message-send-and-exit' and store org link to message copy.
If multiple groups appear in the Gcc header, the link refers to
the copy in the last group."
  (interactive "P")
  (save-excursion
    (save-restriction
      (message-narrow-to-headers)
      (let ((gcc (car (last
                       (message-unquote-tokens
                        (message-tokenize-header
                         (mail-fetch-field "gcc" nil t) " ,")))))
            (buf (current-buffer))
            id to from subject desc link newsgroup xarchive)
        (message-send-and-exit arg)
        (or
         ;; gcc group found ...
         (and gcc
              (save-current-buffer
                (progn (set-buffer buf)
                       (setq id (org-remove-angle-brackets
                                 (mail-fetch-field "Message-ID")))
                       (setq to (mail-fetch-field "To"))
                       (setq from (mail-fetch-field "From"))
                       (setq subject (mail-fetch-field "Subject"))))
              (org-store-link-props :type "gnus" :from from :subject subject
                                    :message-id id :group gcc :to to)
              (setq desc (org-email-link-description))
              (setq link (org-gnus-article-link
                          gcc newsgroup id xarchive))
              (setq org-stored-links
                    (cons (list link desc) org-stored-links)))
         ;; no gcc group found ...
         (message "Can not create Org link: No Gcc header found."))))))

(define-key message-mode-map [(control c) (control meta c)]
  'ulf-message-send-and-org-gnus-store-link)

--8<------------------cut here-----------------end----------------->8---

Ulf

  reply	other threads:[~2010-11-12 13:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-01  9:11 Store link upon sending a message Ulf Stegemann
2010-10-01  9:58 ` Łukasz Stelmach
2010-10-01 10:56   ` Ulf Stegemann
2010-11-12 13:03     ` Ulf Stegemann [this message]
2010-11-12 13:58       ` Eric S Fraga
2010-11-12 14:55         ` Ulf Stegemann
2010-11-12 15:52           ` Eric S Fraga
2010-11-12 16:07             ` Ulf Stegemann
2010-11-12 16:20               ` Eric S Fraga
2010-11-12 15:54           ` Ulf Stegemann
2010-11-12 16:03             ` Eric S Fraga
2011-01-04 17:51       ` Bastien
2011-01-05  7:24         ` Ulf Stegemann
  -- strict thread matches above, loose matches on Subject: below --
2010-10-01  9:01 Ulf Stegemann

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.orgmode.org/

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

  git send-email \
    --in-reply-to=zf.upn7hgizob6.fsf@zeitform.de \
    --to=ulf-news@zeitform.de \
    --cc=emacs-orgmode@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).