From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ulf Stegemann Subject: Re: Store link upon sending a message Date: Fri, 12 Nov 2010 14:03:41 +0100 Message-ID: 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=57467 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGtIT-0004kd-3H for emacs-orgmode@gnu.org; Fri, 12 Nov 2010 08:04:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGtIR-0000xt-Fe for emacs-orgmode@gnu.org; Fri, 12 Nov 2010 08:04:04 -0500 Received: from lo.gmane.org ([80.91.229.12]:40408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGtIR-0000xC-2i for emacs-orgmode@gnu.org; Fri, 12 Nov 2010 08:04:03 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PGtIG-0000sK-By for emacs-orgmode@gnu.org; Fri, 12 Nov 2010 14:03:52 +0100 Received: from london.zeitform.net ([146.140.213.100]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Nov 2010 14:03:51 +0100 Received: from ulf-news by london.zeitform.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Nov 2010 14:03:51 +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: emacs-orgmode@gnu.org 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