emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Usage of org-element api
Date: Sat, 17 Jan 2015 01:33:01 +0100	[thread overview]
Message-ID: <87lhl2b60y.fsf@gmx.us> (raw)
In-Reply-To: CAC2TPPhMuADn5cBeOYcK6nohFrSQ6TR_yH76DC9i8k91utRTHw@mail.gmail.com

Hi Dieter,

Dieter Van Eessen <dieter.van.eessen@gmail.com> 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

  parent reply	other threads:[~2015-01-17  0:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 18:35 Usage of org-element api Dieter Van Eessen
2015-01-16 19:35 ` Rasmus
2015-01-16 21:45   ` Dieter Van Eessen
2015-01-16 22:04     ` Nicolas Goaziou
2015-01-17  0:33     ` Rasmus [this message]
2015-01-17 17:02       ` Dieter Van Eessen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhl2b60y.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).