On Tue, 31 Jul 2007 12:56:18 -0400
Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: 

 xj> Sorry, but I missed the thread.  Where can I grab the code for
 xj> support in org-mode?

Since there were small changes, allow me to repost.

This is a patch against org.el that incorporates mairix into org.el:
--- org.el.orig	2007-07-22 13:52:40.000000000 +0200
+++ org.el	2007-07-30 15:45:10.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,23 @@ 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."
+  (require 'gnus)
+  (funcall (cdr (assq 'gnus org-link-frame-setup)))
+  (if gnus-other-frame-object (select-frame gnus-other-frame-object))
+  (mairix-search string))
+
+(defun org-follow-mairix-link-thread (string)
+  "Follow a Mairix link to its string."
+  (require 'gnus)
+  (funcall (cdr (assq 'gnus org-link-frame-setup)))
+  (if gnus-other-frame-object (select-frame gnus-other-frame-object))
+  (mairix-search-thread string))
+
 (defun org-follow-gnus-link (&optional group article)
   "Follow a Gnus link to GROUP and ARTICLE."
   (require 'gnus)
The patch should be safe to apply in that it should not break anything.

For it to make sense you'll need to glue it into gnus with additional
code, here is the code I use:

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

Beware: This part is a cludge. It works for me, but YMMV.

It allows me to store links the normal way (C-c l) as mairix links and
insert them into my Org files normally (C-c C-l). I can also always
insert the latest SENT mail into my Org files by doing (C-c C-S-l).

Please consider all my stuff under GNU GPL v2 or later (v3 explicitly
allowed) so if someone wants to grab this and turn it into a "clean"
solution, that would be greatly appreciated.

Regards,
Georg


P.S. For completeness, and to make your life easier in trying this, this
is my .mairixrc file:
base=/home/greve
mbox=Archive/Mail/Auto/incoming/????-??:Archive/Mail/Auto/outgoing/????-??
database=/home/greve/Tools/Gnus/MairixDB
mformat=maildir
mfolder=.nnmaildir/mairix
P.P.S. In theory you can also use other backends to access mairix search
results, but I found nnmaildir to be the fastest by far.

-- 
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: pgpzLUG4xKM04.pgp
Description: PGP signature

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

Reply via email to