emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-element - canonical way to parse only headline at point?
@ 2014-07-29 17:33 Thorsten Jolitz
  2014-07-30 16:23 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2014-07-29 17:33 UTC (permalink / raw)
  To: emacs-orgmode


Hi List,

with the new parser, how do I parse only the headline at point?  There
are ARGS in the parser/mapper functions that restrict parsing, but I
suspect that still the whole buffer is parsed for the genealogy - right?

With my current knowledge I would either narrow the buffer to the subtree at
point or copy this subtree to a temp-buffer before parsing/mapping it,
but maybe there is a better way?

Would this be a valid template (a simple and fast solution)?

#+begin_src emacs-lisp
  (save-restriction
   (org-narrow-to-subtree
    (org-element-map (org-element-parse-buffer 'headline t) 'headline
      (lambda () ...)
      nil t t)))
#+end_src

-- 
cheers,
Thorsten

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

* Re: org-element - canonical way to parse only headline at point?
  2014-07-29 17:33 org-element - canonical way to parse only headline at point? Thorsten Jolitz
@ 2014-07-30 16:23 ` Nicolas Goaziou
  2014-07-30 17:23   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2014-07-30 16:23 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

Hello,

Thorsten Jolitz <tjolitz@gmail.com> writes:

> with the new parser, how do I parse only the headline at point?  There
> are ARGS in the parser/mapper functions that restrict parsing, but I
> suspect that still the whole buffer is parsed for the genealogy - right?
>
> With my current knowledge I would either narrow the buffer to the subtree at
> point or copy this subtree to a temp-buffer before parsing/mapping it,
> but maybe there is a better way?
>
> Would this be a valid template (a simple and fast solution)?
>
> #+begin_src emacs-lisp
>   (save-restriction
>    (org-narrow-to-subtree
>     (org-element-map (org-element-parse-buffer 'headline t) 'headline
>       (lambda () ...)
>       nil t t)))
> #+end_src

What about (org-element-at-point) ?


Regards,

-- 
Nicolas Goaziou

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

* Re: org-element - canonical way to parse only headline at point?
  2014-07-30 16:23 ` Nicolas Goaziou
@ 2014-07-30 17:23   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2014-07-30 17:23 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> with the new parser, how do I parse only the headline at point?  There
>> are ARGS in the parser/mapper functions that restrict parsing, but I
>> suspect that still the whole buffer is parsed for the genealogy - right?
>>
>> With my current knowledge I would either narrow the buffer to the subtree at
>> point or copy this subtree to a temp-buffer before parsing/mapping it,
>> but maybe there is a better way?
>>
>> Would this be a valid template (a simple and fast solution)?
>>
>> #+begin_src emacs-lisp
>>   (save-restriction
>>    (org-narrow-to-subtree
>>     (org-element-map (org-element-parse-buffer 'headline t) 'headline
>>       (lambda () ...)
>>       nil t t)))
>> #+end_src
>
> What about (org-element-at-point) ?

Thats why I asked - exactly the function I was looking for. Thanks.

-- 
cheers,
Thorsten

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

end of thread, other threads:[~2014-07-30 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-29 17:33 org-element - canonical way to parse only headline at point? Thorsten Jolitz
2014-07-30 16:23 ` Nicolas Goaziou
2014-07-30 17:23   ` Thorsten Jolitz

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