From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Integration of Org mode and mairix Date: Tue, 07 Aug 2007 19:54:11 +0200 Message-ID: <87ps1z5iyk.fsf@bzg.ath.cx> References: <87r6n6ni2j.fsf@bzg.ath.cx> <20070720160833.GD28297@atlantic.linksys.moosehall> <87k5spsw81.fsf@bzg.ath.cx> <87ejip7ud8.fsf@bzg.ath.cx> <876440tsul.fsf@presario.homelinux.org> <87k5sgpg6o.fsf@bzg.ath.cx> <87lkcqlppr.fsf@presario.homelinux.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IITGP-0001UK-7s for emacs-orgmode@gnu.org; Tue, 07 Aug 2007 13:54:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IITGJ-0001U8-G1 for emacs-orgmode@gnu.org; Tue, 07 Aug 2007 13:54:36 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IITGJ-0001U5-Cy for emacs-orgmode@gnu.org; Tue, 07 Aug 2007 13:54:31 -0400 Received: from nf-out-0910.google.com ([64.233.182.189]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IITGG-0003Zb-1M for emacs-orgmode@gnu.org; Tue, 07 Aug 2007 13:54:30 -0400 Received: by nf-out-0910.google.com with SMTP id f5so575779nfh for ; Tue, 07 Aug 2007 10:54:15 -0700 (PDT) In-Reply-To: (Georg C. F. Greve's message of "Sun\, 05 Aug 2007 12\:20\:37 +0200") 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: "Georg C. F. Greve" Cc: emacs-orgmode@gnu.org --=-=-= "Georg C. F. Greve" writes: > On Sat, 04 Aug 2007 21:44:48 -0400 > Xiao-Yong Jin 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'.) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org.el_07082007.patch 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 " %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): --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=org-mairix.el (setq org-link-custom-types '(("mairix" my-mairix-follow-link my-mairix-store-link gnus-summary-mode))) (defun my-mairix-follow-link (message-id) "Follow a Mairix link." (require 'gnus) (funcall (cdr (assq 'gnus org-link-frame-setup))) (if gnus-other-frame-object (select-frame gnus-other-frame-object)) (mairix-search message-id)) (defun my-mairix-store-link () "Store a mairix link." (let* ((group gnus-newsgroup-name) (article (gnus-summary-article-number)) (header (gnus-summary-article-header article)) (from (mail-header-from header)) (message-id (mail-header-id header)) (date (mail-header-date header)) (subject (gnus-summary-subject-string))) (org-store-link-props :type "mairix" :from from :subject subject :message-id message-id :group group) (setq cpltxt (org-email-link-description)) (setq link (org-make-link "mairix:m:" (substring message-id 1 -1))))) --=-=-= 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 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--