From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: finding a parent node
Date: Tue, 02 Jul 2013 13:06:34 +0200 [thread overview]
Message-ID: <87r4fh43wl.fsf@gmail.com> (raw)
In-Reply-To: 87hagdo0ni.fsf@samsung.com
l.stelmach@samsung.com (Łukasz Stelmach) writes:
Hello Lukasz,
assume my simple-test.org with a :TASK: tag:
#+begin_src org
* header 1
:PROPERTIES:
:CUSTOM_ID: XYZ22
:END:
* header 2 :TASK:
[2013-06-28 Fr 11:01]
** subheader 1
Some text
** subheader 2
More text and a table
| label | col1 | col2 |
|--------+------+------|
| string | 3 | 4 |
Text and a src-block
#+begin_src emacs-lisp
(+ 3 4)
#+end_src
#+end_src
> With my point somewher deep I'like to find the closest parent heading
> tagged :TASKS:.
Lets move point to the source-block and get `org-element-context':
#+begin_src emacs-lisp
(with-current-buffer
(find-file
"/path/to/simple-test.org")
(goto-char (point-min))
(org-babel-next-src-block)
(message "%s" (point))
(format "%s"
(org-element-context)))
#+end_src
#+begin_quote
"(src-block (:language emacs-lisp :switches nil :parameters nil :begin 319
:end 362 :number-lines nil :preserve-indent nil :retain-labels t :use-labels
t :label-fmt nil :hiddenp nil :value (+ 3 4) :post-blank 0 :post-affiliated
319 :parent nil))"
#+end_quote
too bad, does not work in isolated use, :parent is nil. Othewise one could
get the parent(s) and check for the :TASK: tag.
So the only way to find this headline I know of would be:
#+begin_src emacs-lisp
(with-current-buffer
(find-file-noselect
"/path/to/simple-test.org")
(let ((tree (org-element-parse-buffer)))
(org-element-map tree 'headline
(lambda (hl)
(and
(member "TASK" (org-element-property :tags hl))
(list (org-element-property :begin hl)
(org-element-property :end hl)))))))
#+end_src
returns
,-----------
| ((55 362))
`-----------
so you could at least find out if (point) is inside a headline with a :TASK:
tag, then get this headline and use its attribute list to move to some place
inside of it.
But I'm sure Nicolas can give you a much better solution (I would be
interested in that solution too).
--
cheers,
Thorsten
next prev parent reply other threads:[~2013-07-02 11:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 7:56 finding a parent node Łukasz Stelmach
2013-07-02 9:40 ` Thorsten Jolitz
2013-07-02 11:06 ` Thorsten Jolitz [this message]
2013-07-02 11:35 ` Łukasz Stelmach
2013-07-02 12:12 ` Thorsten Jolitz
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r4fh43wl.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.