From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Usage of org-element api Date: Sat, 17 Jan 2015 01:33:01 +0100 Message-ID: <87lhl2b60y.fsf@gmx.us> References: <87r3uu34dm.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCHKF-0005ga-BU for emacs-orgmode@gnu.org; Fri, 16 Jan 2015 19:33:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YCHKC-00085U-4P for emacs-orgmode@gnu.org; Fri, 16 Jan 2015 19:33:15 -0500 Received: from plane.gmane.org ([80.91.229.3]:53931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCHKB-00083j-Tv for emacs-orgmode@gnu.org; Fri, 16 Jan 2015 19:33:12 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YCHK9-0006lL-6d for emacs-orgmode@gnu.org; Sat, 17 Jan 2015 01:33:09 +0100 Received: from 46.166.186.240 ([46.166.186.240]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Jan 2015 01:33:09 +0100 Received: from rasmus by 46.166.186.240 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Jan 2015 01:33:09 +0100 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: emacs-orgmode@gnu.org Hi Dieter, Dieter Van Eessen writes: > Hello Rasmus, > > Thank you for the fast reply, the link you've given on interpreting is very > useful ! Also didn't know there existed such thing as the org-dp library to > manipulate org-elements, I'll sure check it out. I don't know org-dp myself, but Thorsten posts here regularly. > More about question number 3: >>> 3) How can the output of (org-element-parse-secondary-string ...) be >>> used. >>> When I give a heading and bit of text as input (output of >>> buffer-substring), it looks like it returns the 'content' of the region. >>> Though I can't seem to use it anyway as 'CONTENT' for the functions >>> requiring this. > > The reason I've tried this (and the internal org-element--parse-elements) > is because I'd prefer not having to parse the whole buffer and still get > the contents. The local parsing functions (org-element-at-point) and > (org-element-context) don't contain content (stated in the org-element api, > also tried it). But all elements contain :begin and :end and most :contens-begin and :contents-end (maybe sans an 's'). > Now I'm not sure IF I really NEED it? I could actually get the contents > using the :content-begin and :content-end and other properties from > (org-elemen-at-point) BUT I don't know the exact syntax the content should > have and how to merge it with the element-list I get from > (org-element-at-point) before feeding it to the org-element-interpret-data. Maybe it would be easier if you state plainly what your desired goal is? It's all a bit abstract. You can write pretty sophisticated things using just (org-element-at-point) (e.g. I have a function that escapes *math-su{b,per}script* on double space at appropriate places). > [...] > At first I thought that the things behind # were 'content' (for example in > the output below. These don't show up in (org-element-at-point), thus > explaining why they returned nil when asked for content. The > org-element-parse-secondary-string also returns all things behind #. If > this is NOT content, then how to manipulate this data (behind the #) whilst > assuring that syntax and position remains valid for > org-element-interpret-data to understand? If you want to manipulate the buffer text use the great functions. You can condition on the element under point or whatever you desire and then use the regular functions you'd otherwise use. I'm probably wrong, but it seems as if you trying to shoot flies with canons, or however the saying goes in English. Also, recall there is no such thing as wrong Org-syntax (but there is unexpected outcomes). Check Org.el if you want. Cheers, Rasmus -- Not everything that goes around comes back around, you know