all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Use of attribute :parent in org-element.el
@ 2013-04-19 13:20 Thorsten Jolitz
  2013-04-19 15:07 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2013-04-19 13:20 UTC (permalink / raw)
  To: emacs-orgmode


Hi List,

while playing around a bit with two quite useful functions from
org-element.el described here

,--------------------------------------------------------------------
| The library ends by furnishing `org-element-at-point' function, and
| a way to give information about document structure around point
| with `org-element-context'.
`--------------------------------------------------------------------

a few questions arose. I used org-outside-org.org from Worg
(http://orgmode.org/worg/org-tutorials/org-outside-org.html) as an
example file, here is an excerpt of its tree-structure:

,----------------------------------
| buffer: org-outside-org.org
|      15:* Introduction
|      46:* Org-mode everywhere
|      50:** File Structuring
|      54:*** Orgstruct 
|      94:*** Outline with Outshine [...]
`----------------------------------

Each of the headlines in this file has a property drawer like this:

   ,-----------------------------
   | :PROPERTIES:
   | :CUSTOM_ID: file-structuring
   | :END:
   `-----------------------------

1. Question wrt Attribute :parent

(i) With point before the property-drawer of headline 

,--------------------
| ** File Structuring
`--------------------

evaluating this 

,-------------------------------------
| (format "%s" (org-element-at-point))
`-------------------------------------

yields

,-----------------------------------------------------------------------
| "(property-drawer (:begin 2381 :end 2438 :hiddenp outline
| :contents-begin 2397 :contents-end 2429 :post-blank 0 :post-affiliated
| 2381 :parent nil))"
`-----------------------------------------------------------------------

(ii) With point before headline

,--------------------
| ** File Structuring
`--------------------

evaluating

,-------------------------------------
| (format "%s" (org-element-at-point))
`-------------------------------------

yields

,---------------------------------------------------------------------
| "(headline (:raw-value File Structuring :begin 2361 :end 11523
| :pre-blank 0 :hiddenp nil :contents-begin 2381 :contents-end 11522
| :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil
| :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil
| :quotedp nil :CUSTOM_ID file-structuring :CATEGORY worg :title File
| Structuring))"
`---------------------------------------------------------------------

The use of the :parent attribute is surprising for me. I would have
expected something like ':parent org-mode everywhere' in the second
example, i.e. the title of the 1st level subtree containing the 2nd
level headline at point. 

I'm not sure what I would have expected in the first example. What is
the parent of an element that is contained in a greater element that has
a parent? Is it nil, or is it the parent of its containing greater
element?

-- 
cheers,
Thorsten

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

* Re: Use of attribute :parent in org-element.el
  2013-04-19 13:20 Use of attribute :parent in org-element.el Thorsten Jolitz
@ 2013-04-19 15:07 ` Nicolas Goaziou
  2013-04-19 15:37   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2013-04-19 15:07 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

Hello,

Thorsten Jolitz <tjolitz@gmail.com> writes:

> The use of the :parent attribute is surprising for me. I would have
> expected something like ':parent org-mode everywhere' in the second
> example, i.e. the title of the 1st level subtree containing the 2nd
> level headline at point.

`org-element-at-point' and `org-element-context' return information
about the close neighbourhood of point, which is the current section. In
other words, each element at top level within the section get
a nil :parent property.

As a special case, when point is at a headline, each function returns
the parsed headline, without any :parent property defined (it would be
out of the scope of these functions).

> I'm not sure what I would have expected in the first example. What is
> the parent of an element that is contained in a greater element that has
> a parent? Is it nil, or is it the parent of its containing greater
> element?

If you parse completely the buffer with `org-element-parse-buffer', you
will see that genealogy for property drawer goes like this:

  property-drawer > section > headline > headline > org-data


Regards,

-- 
Nicolas Goaziou

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

* Re: Use of attribute :parent in org-element.el
  2013-04-19 15:07 ` Nicolas Goaziou
@ 2013-04-19 15:37   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2013-04-19 15:37 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> The use of the :parent attribute is surprising for me. I would have
>> expected something like ':parent org-mode everywhere' in the second
>> example, i.e. the title of the 1st level subtree containing the 2nd
>> level headline at point.
>
> `org-element-at-point' and `org-element-context' return information
> about the close neighbourhood of point, which is the current section. In
> other words, each element at top level within the section get
> a nil :parent property.
>
> As a special case, when point is at a headline, each function returns
> the parsed headline, without any :parent property defined (it would be
> out of the scope of these functions).
>
>> I'm not sure what I would have expected in the first example. What is
>> the parent of an element that is contained in a greater element that has
>> a parent? Is it nil, or is it the parent of its containing greater
>> element?
>
> If you parse completely the buffer with `org-element-parse-buffer', you
> will see that genealogy for property drawer goes like this:
>
>   property-drawer > section > headline > headline > org-data

I understand, thanks, so the whole info is only available when parsing
the complete buffer. 

-- 
cheers,
Thorsten

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

end of thread, other threads:[~2013-04-19 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-19 13:20 Use of attribute :parent in org-element.el Thorsten Jolitz
2013-04-19 15:07 ` Nicolas Goaziou
2013-04-19 15:37   ` Thorsten Jolitz

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.