emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Getting text at position?
@ 2019-06-10  2:42 Mike Gauland
  2019-06-10  3:35 ` Kyle Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Gauland @ 2019-06-10  2:42 UTC (permalink / raw)
  To: emacs-orgmode

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?

Kind regards,
Mike

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Getting text at position?
  2019-06-10  2:42 Getting text at position? Mike Gauland
@ 2019-06-10  3:35 ` Kyle Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2019-06-10  3:35 UTC (permalink / raw)
  To: Mike Gauland, emacs-orgmode

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-10  3:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10  2:42 Getting text at position? Mike Gauland
2019-06-10  3:35 ` Kyle Meyer

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).