[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Store link upon sending a message

From: Ulf Stegemann
Subject: [Orgmode] Re: Store link upon sending a message
Date: Fri, 12 Nov 2010 14:03:41 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

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")
      (let ((gcc (car (last
                         (mail-fetch-field "gcc" nil t) " ,")))))
            (buf (current-buffer))
            id to from subject desc link newsgroup xarchive)
        (message-send-and-exit arg)
         ;; gcc group found ...
         (and gcc
                (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)]

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]