emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Support for linking to nnml (Gnus) mail messages by Message-ID
@ 2007-09-04 19:04 John Wiegley
  2007-09-05  3:23 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: John Wiegley @ 2007-09-04 19:04 UTC (permalink / raw)
  To: emacs-orgmode

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 <johnw@gnu.org>

(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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Support for linking to nnml (Gnus) mail messages by Message-ID
  2007-09-04 19:04 Support for linking to nnml (Gnus) mail messages by Message-ID John Wiegley
@ 2007-09-05  3:23 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2007-09-05  3:23 UTC (permalink / raw)
  To: John Wiegley; +Cc: emacs-orgmode

Note that John is running an intermediate version with a small fix 
needed
to make this work.  Wait for 5.08 before trying this...

- Carsten

On Sep 4, 2007, at 21:04, John Wiegley wrote:

> 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 <johnw@gnu.org>
>
> (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
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-05  3:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-04 19:04 Support for linking to nnml (Gnus) mail messages by Message-ID John Wiegley
2007-09-05  3:23 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).