From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: problem with org-element-parse-buffer Date: Sun, 25 Nov 2012 10:11:49 +0100 Message-ID: <87a9u63v3e.fsf@gmail.com> References: <87haovrwcs.fsf@micropit.couberia.selfip.net> <87y5i76qfv.fsf@gmail.com> <877gpbrz1g.fsf@micropit.couberia.selfip.net> <87ehjjkx8n.fsf@gmail.com> <87lidqwbix.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:41822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcYJo-0004xA-L1 for emacs-orgmode@gnu.org; Sun, 25 Nov 2012 04:16:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TcYJn-00046k-At for emacs-orgmode@gnu.org; Sun, 25 Nov 2012 04:16:04 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:65017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcYJn-00046d-5G for emacs-orgmode@gnu.org; Sun, 25 Nov 2012 04:16:03 -0500 Received: by mail-wi0-f169.google.com with SMTP id hq12so1986634wib.0 for ; Sun, 25 Nov 2012 01:16:02 -0800 (PST) In-Reply-To: <87lidqwbix.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 25 Nov 2012 12:29:26 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Abrahamsen Cc: emacs-orgmode@gnu.org Hello, Eric Abrahamsen writes: >> Strictly speaking, yes. But Org Agenda is a bit permissive (and not only >> for that thing). Do you want to help basing Agenda on Elements? > > This is something I was wondering about -- so that is the plan > eventually? Since we have a complete parser, it would be good to use it as much as possible. It will alleviate the need to use regexps and normalize Org syntax. One downside, though, is that it isn't fast enough yet for speed critical operations (i.e. fontification). A caching mechanism would be required to go further (any taker?). Org Elements is quite simple to use: API basically boils down to five functions. For a global action, the main function to use is `org-element-parse-buffer'. At the element level (paragraphs, tables...), it is `org-element-at-point'. At the object level (links, emphasis...), it is `org-element-context'. Then you extract properties (resp. type) with `org-element-property' (resp. `org-element-type'). You can get a list of all properties available for each element/object by looking at: http://orgmode.org/worg/dev/org-export-reference.html#attributes or by looking at org-element.el source code, obviously. In order to get started, you can study navigation/manipulation functions in org.el (from `org-forward-element' to `org-unindent-buffer'). > This is something I've wanted for a while, as it would make > some of my little personal projects a lot easier. I'd be happy to help > if there's a roadmap, and if I can be fed bite-sized problems to deal > with. There's no roadmap for now. If you're looking for small tasks to handle, I think interactive functions are a good start (although some can be a bit challenging, i.e. `org-open-link'). Particularly good candidates are those calling either `org-at-regexp-p', `org-in-regexp' or `org-between-regexps-p': using those is almost always wrong (or at least fragile). If you give a shot at some of them, please include ert tests: writings tests for Org is really a must from now on. There are now plenty of examples in testing directory. Thank you for your interest in this. Regards, -- Nicolas Goaziou