[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Expose value-begin and value-end instead of just value in org-el
From: |
Somelauw . |
Subject: |
Re: [O] Expose value-begin and value-end instead of just value in org-element API |
Date: |
Wed, 21 Feb 2018 22:13:33 +0100 |
Thank you for your response.
2018-02-21 12:17 GMT+01:00 Nicolas Goaziou <address@hidden>:
> You get the beginning of the code of a source block with
>
> (org-with-point-at (org-element-property :post-affiliated element)
> (line-beginning-position 2))
>
> and its end with
>
> (org-with-point-at (org-element-property :end element)
> (line-beginning-position (- (org-element-property :post-blank element))))
This works well to find the :value of code blocks, but doesn't work
for other org elements such as clock, babel-call and comment. What I'm
looking for is a generic way to find the beginning and end of the
:value of the element at point that works on all elements and is
future-proof.
>>> - More powerful. In my evil-org plugin I want to be able to mark the value
>>> property of the org element at point (so the user can do stuff like easily
>>> copy the code of the current code block), but to do so I need the beginning
>>> and ending position in the buffer of "value". The org-element API does
>>> currently not provide clean way to retrieve these positions.
>
> See above. It is quite simple to extract this information from the parse
> tree.
Something I would like to have is a command to mark the "useful inner
part" of the element that the point is currently on. For recursive
elements this is usually the part between :contents-begin and
:contents-end and for non-recursive elements this is usually :value.
The org-element-parser was probably not written for the specific goal
I have in mind, but the :value of org-element gives me almost what I
want, except that I need the buffer positions.
Kind regards,
Somelauw