"Georg C. F. Greve" <[EMAIL PROTECTED]> writes:

> On Sat, 04 Aug 2007 21:44:48 -0400
> Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: 
>
>  xj> Perhaps we should actually suggest Carsten build nnir support in
>  xj> org-mode and at the same time persuade the maintainer of nnir.el to
>  xj> support mairix?  ;-)
>
> I think this could be a clean solution to the problem.

Here is a patch against latest org-mode 5.04 as a first attempt of
implementing custom link-types (stored in `org-link-custom-types'.)

diff --git a/org.el b/org.el
index 1fc081e..c139be1 100644
--- a/org.el
+++ b/org.el
@@ -968,6 +968,23 @@ Automatically means, when TAB or RET or C-c C-c are pressed in the line."
 The value of this is taken from the #+LINK lines.")
 (make-variable-buffer-local 'org-link-abbrev-alist-local)
 
+(defcustom org-link-custom-types nil
+  "Alist of recognized link types.  
+This types are appended to `org-link-types'.
+Each cell is of the form 
+
+  \(\"type\" \(follow-function store-function major-mode\)\)
+
+where \"type\" is the string defining the type, follow-function
+is the function that Org will call to follow these links,
+store-function the function that Org will use to store these link
+and major-mode the major mode where it's active."
+  :group 'org-link
+  :type '(repeat (list (string :tag "Type (string)       ")
+		       (function :tag "Follow function     ")
+		       (function :tag "Store function      ")
+		       (function :tag "Active in major mode"))))
+
 (defcustom org-link-abbrev-alist nil
   "Alist of link abbreviations.
 The car of each element is a string, to be replaced at the start of a link.
@@ -4140,8 +4157,11 @@ that will be added to PLIST.  Returns the string that was modified."
 (require 'font-lock)
 
 (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"))
+(defconst org-link-types 
+  (append (list "http" "https" "ftp" "mailto" "file" "news" "bbdb" "vm"
+		"wl" "mhe" "rmail" "gnus" "shell" "info" "elisp")
+	  (delq nil (mapcar (lambda(x) (car x)) org-link-custom-types))))
+
 (defconst org-link-re-with-space
   (concat
    "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
@@ -10410,9 +10430,13 @@ For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
 For file links, arg negates `org-context-in-file-links'."
   (interactive "P")
   (setq org-store-link-plist nil)  ; reset
-  (let (link cpltxt desc description search txt)
+  (let (link cpltxt desc description search txt cus)
     (cond
 
+     ((setq cus (assq major-mode (mapcar '(lambda(e) (reverse e)) 
+					 org-link-custom-types)))
+      (funcall (nth 1 cus)))
+
      ((eq major-mode 'bbdb-mode)
       (let ((name (bbdb-record-name (bbdb-current-record)))
 	    (company (bbdb-record-getprop (bbdb-current-record) 'company)))
@@ -11006,7 +11030,7 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
   (org-remove-occur-highlights nil nil t)
   (if (org-at-timestamp-p t)
       (org-follow-timestamp-link)
-    (let (type path link line search (pos (point)))
+    (let (type path link line search (pos (point)) cus)
       (catch 'match
 	(save-excursion
 	  (skip-chars-forward "^]\n\r")
@@ -11177,7 +11201,10 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
               (message "%s => %s" cmd (eval (read cmd)))
 	    (error "Abort"))))
 
-       (t
+       ((setq cus (assoc type org-link-custom-types))
+	(funcall (nth 1 cus) path))
+
+       (t 
 	(browse-url-at-point)))))
   (move-marker org-open-link-marker nil))
 
It lets you define an alist of custom link-types. See the docstring of
`org-link-custom-types'.

Then you need to define the follow/store functions by yourself. Here are
the defuns I use (in addition to Georg's mairix.el):

Attachment: org-mairix.el
Description: application/emacs-lisp

I think the nnir.el support could be provided via custom link types,
instead of being hardcoded within org.el.

Please test it and give me feedback! 

PS: i started to have a look at nnir.el to make it aware of mairix. But
i'm not sure i'll have time for this till the end of the week.

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

Reply via email to