From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Wiegley Subject: Support for linking to nnml (Gnus) mail messages by Message-ID Date: Tue, 04 Sep 2007 15:04:20 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ISdhK-0006wq-3t for emacs-orgmode@gnu.org; Tue, 04 Sep 2007 15:04:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ISdhJ-0006wU-6L for emacs-orgmode@gnu.org; Tue, 04 Sep 2007 15:04:25 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ISdhJ-0006wN-1v for emacs-orgmode@gnu.org; Tue, 04 Sep 2007 15:04:25 -0400 Received: from wx-out-0506.google.com ([66.249.82.230]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ISdhI-00088q-1b for emacs-orgmode@gnu.org; Tue, 04 Sep 2007 15:04:24 -0400 Received: by wx-out-0506.google.com with SMTP id s7so1762833wxc for ; Tue, 04 Sep 2007 12:04:23 -0700 (PDT) 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 Because I frequently archive out e-mails to other mailboxes, I cannot rely on the group/article-no format of the current Gnus e-mail links used by org.el. So, I've written code that can find a message based solely on its Message-ID. The only requirement is that the message must be in an nnml mailbox somewhere, and not in mbox format or something else. John ;;; org-nnml.el - Support for links to nnml messages by Message-ID ;; version 1.0, by John Wiegley (require 'org) (eval-when-compile (require 'nnml) (require 'gnus-sum)) (org-add-link-type "nnml" 'org-nnml-open) (add-hook 'org-store-link-functions 'org-nnml-store-link) (defun org-nnml-open (message-id) "Visit the nnml message with the given Message-ID." (let ((info (nnml-find-group-number message-id))) (gnus-summary-read-group (concat "nnml:" (car info)) 100 t) (gnus-summary-goto-article (cdr info) nil t))) (defun org-nnml-store-link () "Store a link to an nnml e-mail message by Message-ID." (when (memq major-mode '(gnus-summary-mode gnus-article-mode)) (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary)) (let* ((article (gnus-summary-article-number)) (header (gnus-summary-article-header article)) (message-id (mail-header-id header))) (if (eq (aref message-id 0) ?\<) (setq message-id (substring message-id 1 (1- (length message-id))))) (org-store-link-props :type "nnml" :link (cons (concat "nnml://" message-id) (concat "nnml://" message-id)) :description (mail-header-subject header))))) (provide 'org-nnml) ;;; org-nnml.el ends here