From: "Somelauw ." <somelauw@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>,
John Kitchin <jkitchin@andrew.cmu.edu>
Subject: Re: Expose value-begin and value-end instead of just value in org-element API
Date: Wed, 21 Feb 2018 22:13:33 +0100 [thread overview]
Message-ID: <CA+gt_a9Z3WrXRMhvoJMG+DRmq-ffAAiBStMa8b54nVPvkV-wnQ@mail.gmail.com> (raw)
In-Reply-To: <87k1v6k2wt.fsf@nicolasgoaziou.fr>
Thank you for your response.
2018-02-21 12:17 GMT+01:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:
> 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
next prev parent reply other threads:[~2018-02-21 21:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-19 23:29 Expose value-begin and value-end instead of just value in org-element API Somelauw .
2018-02-20 19:59 ` John Kitchin
2018-02-21 11:17 ` Nicolas Goaziou
2018-02-21 21:13 ` Somelauw . [this message]
2018-02-26 3:43 ` John Kitchin
2018-02-26 10:05 ` Nicolas Goaziou
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=CA+gt_a9Z3WrXRMhvoJMG+DRmq-ffAAiBStMa8b54nVPvkV-wnQ@mail.gmail.com \
--to=somelauw@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jkitchin@andrew.cmu.edu \
--cc=mail@nicolasgoaziou.fr \
/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).