On Fri, 20 Jul 2007 17:08:33 +0100
Adam Spiers <[EMAIL PROTECTED]> wrote: 

 as> Funnily enough, I implemented exactly this idea about 15 months
 as> ago, except that my implementation uses mairix (the mail indexer),
 as> and is mode-agnostic.

Thanks a lot, this is most interesting and put me on the right track.

Combining your work with that of Guy Hillenius, which he blogged at
http://www.hillenius.net/node/44 I integrated Gnus, Mairix & Org now.

The core is a patch for org.el -- this patch is still somewhat
primitive, but should not break anything and unless the new variables
are changed will not change standard behaviour:

--- org.el.orig	2007-07-22 13:52:40.000000000 +0200
+++ org.el	2007-07-22 17:44:51.000000000 +0200
@@ -1100,6 +1100,18 @@ negates this setting for the duration of
   :group 'org-link-store
   :type 'boolean)
 
+(defcustom org-gnus-links-prefer-mairix nil
+  "Non-nil means, `org-store-link' will create links to Mairix searches for gnus.
+When nil, traditional Gnus links (group & article) will be used for such links."
+  :group 'org-link-store
+  :type 'boolean)
+
+(defcustom org-mairix-links-prefer-threaded nil
+  "Non-nil means, that links to Mairix searches will be stored as thread searches.
+   When nil, the links to Mairix searches will be stored as single message searches."
+  :group 'org-link-store
+  :type 'boolean)
+
 (defgroup org-link-follow nil
   "Options concerning following links in Org-mode"
   :tag "Org Follow Link"
@@ -4141,7 +4153,7 @@ that will be added to PLIST.  Returns th
 
 (defconst org-non-link-chars "]\t\n\r<>")
 (defconst org-link-types '("http" "https" "ftp" "mailto" "file" "news" "bbdb" "vm"
-			   "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp"))
+			   "wl" "mhe" "rmail" "mairix" "mairixt" "gnus" "shell" "info" "elisp"))
 (defconst org-link-re-with-space
   (concat
    "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
@@ -10537,14 +10549,18 @@ For file links, arg negates `org-context
 	(org-store-link-props :type "gnus" :from from :subject subject
 			      :message-id message-id :group group)
 	(setq cpltxt (org-email-link-description))
-	(if (org-xor arg org-usenet-links-prefer-google)
-	    (setq link
-		  (concat
-		   cpltxt "\n  "
-		   (format "http://groups.google.com/groups?as_umsgid=%s";
-			   (org-fixup-message-id-for-http message-id))))
-	  (setq link (org-make-link "gnus:" group
-				    "#" (number-to-string article))))))
+	(if org-gnus-links-prefer-mairix
+	    (if org-mairix-links-prefer-threaded
+		(setq link (org-make-link "mairixt:m:" (substring message-id 1 -1)))
+	      (setq link (org-make-link "mairix:m:" (substring message-id 1 -1))))
+	  (if (org-xor arg org-usenet-links-prefer-google)
+	      (setq link
+		    (concat
+		     cpltxt "\n  "
+		     (format "http://groups.google.com/groups?as_umsgid=%s";
+			     (org-fixup-message-id-for-http message-id))))
+	    (setq link (org-make-link "gnus:" group
+				    "#" (number-to-string article)))))))
 
      ((eq major-mode 'w3-mode)
       (setq cpltxt (url-view-url t)
@@ -11105,6 +11121,12 @@ optional argument IN-EMACS is non-nil, E
        ((string= type "news")
 	(org-follow-gnus-link path))
 
+       ((string= type "mairix")
+	(org-follow-mairix-link path))
+
+       ((string= type "mairixt")
+	(org-follow-mairix-link-thread path))
+
        ((string= type "bbdb")
 	(org-follow-bbdb-link path))
 
@@ -11473,6 +11495,17 @@ onto the ring."
           (Info-find-node (match-string 1 name) "Top")))
     (message (concat "Could not open: " name))))
 
+; the following two org-follow-mairix functions should be generalised 
+; to deal with the different mail readers, right now they simply hook
+; into some primitive gnus glue
+(defun org-follow-mairix-link (string)
+  "Follow a Mairix link to its string."
+  (mairix-search string))
+
+(defun org-follow-mairix-link-thread (string)
+  "Follow a Mairix link to its string."
+  (mairix-search-thread string))
+
 (defun org-follow-gnus-link (&optional group article)
   "Follow a Gnus link to GROUP and ARTICLE."
   (require 'gnus)
But if someone feels like improving this so it can go into mainstream
org.el, that would be great.

Right now it needs some glue in your .gnus.el

Attachment: binOBpAvi4mNQ.bin
Description: application/emacs-lisp

and you should configure .mairixrc to store its search results where
Gnus stores its nnmaildir data. Mine looks like this:

base=/home/greve
mbox=Archive/Mail/Auto/incoming/????-??:Archive/Mail/Auto/outgoing/????-??
mformat=maildir
mfolder=.nnmaildir/mairix
database=/home/greve/Tools/Gnus/MairixDB
With this you can store Org links as mairix links, including the
possibility to store links to emails that will pull the entire thread
that contains this message into the temporary buffer -- so you'll only
need to link to one and always get the entire thread.

For convenience it also makes sense to define some key bindings.

This gives as much functionality as "normal" Gnus integration otherwise,
although now it is no longer needed to know WHERE things are stored, as
mairix will find it regardless of final location.

So this solves the most urgent problem for me with the old Gnus links
and will hopefully be useful for some others, too.

On top of this some more sophisticated integration might be set up,
although http://thread.gmane.org/gmane.emacs.orgmode/1771 does not
really help me too much, as I have multiple agenda files in which I like
to store things.

Regards,
Georg

-- 
Georg C. F. Greve                                 <[EMAIL PROTECTED]>
Free Software Foundation Europe                  (http://fsfeurope.org)
Join the Fellowship and protect your freedom!     (http://www.fsfe.org)
What everyone should know about DRM                   (http://DRM.info)

Attachment: pgpaQxUua08hf.pgp
Description: PGP signature

_______________________________________________
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to