emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Return Top-Level Heading
@ 2015-10-13 15:35 Zach Sheffler
  2015-10-19 22:24 ` Myles English
  0 siblings, 1 reply; 2+ messages in thread
From: Zach Sheffler @ 2015-10-13 15:35 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

Hello,

Is there a way to reference the top-level heading that a lower-level
heading belongs to? For instance:

* One
** Two
*** Three

If I have "Three", how can I get it to tell me that the top-level is "One"?
For reference, this is for an org-agenda-prefix.

Thanks!

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

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

* Re: Return Top-Level Heading
  2015-10-13 15:35 Return Top-Level Heading Zach Sheffler
@ 2015-10-19 22:24 ` Myles English
  0 siblings, 0 replies; 2+ messages in thread
From: Myles English @ 2015-10-19 22:24 UTC (permalink / raw)
  To: Zach Sheffler; +Cc: emacs-orgmode@gnu.org

Hello Zach,

Zach Sheffler writes:

> Is there a way to reference the top-level heading that a lower-level
> heading belongs to? For instance:
>
> * One
> ** Two
> *** Three
>
> If I have "Three", how can I get it to tell me that the top-level is "One"?
> For reference, this is for an org-agenda-prefix.

Perhaps this:

(defun findTop()
    (interactive)
    (let* ((tree (org-element-parse-buffer))
           (curs_pos (point))
           (up_tree (org-element-map tree 'headline
                      (lambda (hl)
                        (and (> curs_pos (org-element-property :begin hl))
                             (= (org-element-property :level hl) 1)
                             (org-element-property :raw-value hl) ))))
           (local_up_tree (last up_tree)))
      local_up_tree))

Myles

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

end of thread, other threads:[~2015-10-19 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 15:35 Return Top-Level Heading Zach Sheffler
2015-10-19 22:24 ` Myles English

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