emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Re: Store link upon sending a message


From: Bastien
Subject: Re: [Orgmode] Re: Store link upon sending a message
Date: Tue, 04 Jan 2011 18:51:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Hi Ulf,

Ulf Stegemann <address@hidden> writes:

> (defun ulf-message-send-and-org-gnus-store-link (&optional arg)

This is something I've been trying to achieve for very long!  Great 
you found a solution.  A minor suggestion: the function should make 
sure the buffer is not killed after the message is sent.

I added (message-kill-buffer-on-exit nil) like this:

--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))
              (message-kill-buffer-on-exit nil)
              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."))))))
--8<---------------cut here---------------end--------------->8---

I also added an entry in org-hacks.org.

Thanks!

-- 
 Bastien



reply via email to

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