emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Mike Gauland <mikelygee@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Getting text at position?
Date: Sun, 09 Jun 2019 23:35:30 -0400	[thread overview]
Message-ID: <87wohuglj1.fsf@kyleam.com> (raw)
In-Reply-To: <80214e4f-d9e5-1daa-8c91-116c19bfff59@gmail.com>

Mike Gauland <mikelygee@gmail.com> writes:

> I'd like to be able to be able to get the text associated with a given 
> heading (based on the current point, for example).
>
> Can anyone point me to an example for doing this in the approved manner 
> (assuming there is one), or to functions to help with this?

Don't trust me to give you an approved manner, but a couple of options:

  * If you just care about headlines and assuming you want all
    associated content, including the headline text itself, perhaps
    calling org-copy-subtree non-interactively will suffice.

    If that doesn't behave how you want, looking at org-copy-subtree's
    source could still give you an idea of how to do what you want in
    elisp.

  * You could use the org-element API to get the information and likely
    could easily tweak something like below to suit your needs.

     (and (ignore-errors (org-back-to-heading t))
          (let ((el (org-element-at-point)))
            (buffer-substring
             (org-element-property :begin el)
             (org-element-property :end el))))

-- 
Kyle

      reply	other threads:[~2019-06-10  3:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10  2:42 Getting text at position? Mike Gauland
2019-06-10  3:35 ` Kyle Meyer [this message]

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=87wohuglj1.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mikelygee@gmail.com \
    /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).