From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Re: Store link upon sending a message Date: Tue, 04 Jan 2011 18:51:30 +0100 Message-ID: <87k4ik1rrx.fsf@altern.org> References: <87wrq29qvi.fsf@dasa3.iem.pw.edu.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=35645 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaB2y-00066f-8F for emacs-orgmode@gnu.org; Tue, 04 Jan 2011 12:51:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PaB2x-0003Ou-0W for emacs-orgmode@gnu.org; Tue, 04 Jan 2011 12:51:48 -0500 Received: from mail-ww0-f49.google.com ([74.125.82.49]:61424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PaB2w-0003Oq-PQ for emacs-orgmode@gnu.org; Tue, 04 Jan 2011 12:51:46 -0500 Received: by wwb17 with SMTP id 17so15076751wwb.30 for ; Tue, 04 Jan 2011 09:51:46 -0800 (PST) In-Reply-To: (Ulf Stegemann's message of "Fri, 12 Nov 2010 14:03:41 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ulf Stegemann Cc: emacs-orgmode@gnu.org Hi Ulf, Ulf Stegemann 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