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


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to