emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* get current headline?
@ 2016-02-19 20:41 Matt Price
  2016-02-20 15:45 ` Rasmus
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Price @ 2016-02-19 20:41 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 789 bytes --]

I feel like I should know how to do this -- how od I retrieve the current
headline as an org-element object?

context: I want to take a headline like this

** Jane Doe
- demonstrates an understanding of research topic  :: yes
- Annotated Bibliography :: very nicely done
- Grammar and Spelling :: no major problems, but see inline comments
- Further Comments :: see file
- Grade :: A

And set the headline's "GRADE" property to the value of the "- Grade ::"
line.  But, I want to make sure that I'm still in the current headline when
I set the property (rather than accidentally navigating to the next
headline, because the current headline doesn't contain a "- Grade ::" lin).

Tanks as always for the help! I'm pretty sure I've asked this question
before but can't find the answer...

m

[-- Attachment #2: Type: text/html, Size: 987 bytes --]

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

* Re: get current headline?
  2016-02-19 20:41 get current headline? Matt Price
@ 2016-02-20 15:45 ` Rasmus
  0 siblings, 0 replies; 2+ messages in thread
From: Rasmus @ 2016-02-20 15:45 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Matt Price <moptop99@gmail.com> writes:

> I feel like I should know how to do this -- how od I retrieve the current
> headline as an org-element object?
>
> context: I want to take a headline like this
>
> ** Jane Doe
> - demonstrates an understanding of research topic  :: yes
> - Annotated Bibliography :: very nicely done
> - Grammar and Spelling :: no major problems, but see inline comments
> - Further Comments :: see file
> - Grade :: A
>
> And set the headline's "GRADE" property to the value of the "- Grade ::"
> line.  But, I want to make sure that I'm still in the current headline when
> I set the property (rather than accidentally navigating to the next
> headline, because the current headline doesn't contain a "- Grade ::" lin).
>
> Tanks as always for the help! I'm pretty sure I've asked this question
> before but can't find the answer...

Would this do what you want?

(save-excursion
  (org-back-to-heading)
  (org-element-at-point))

If you have a more sophisticated parse tree you could use
org-element-lineage.

Rasmus

-- 
Don't slow down Johnny, leave the Cadillac runnin'

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

end of thread, other threads:[~2016-02-20 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 20:41 get current headline? Matt Price
2016-02-20 15:45 ` Rasmus

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