Re: [O] Use org-element to figure out if I am in a drawer.

2013-11-26 Thread Nicolas Goaziou
Hello,

Carsten Dominik  writes:

> Hmmm,
>
> what is the magic incantation to use org-element to figure out if
> point is currently inside a drawer?

Something like:

  (let ((element (org-element-at-point)))
(while (and element
(not (memq (org-element-type element) '(drawer 
property-drawer
  (setq element (org-element-property :parent element)))
element)

which should return containing drawer or nil.


Regards,

-- 
Nicolas Goaziou



Re: [O] Use org-element to figure out if I am in a drawer.

2013-11-26 Thread Rasmus
Carsten Dominik  writes:

> Hmmm,
>
> what is the magic incantation to use org-element to figure out if
> point is currently inside a drawer?

What about org-element-at-point?

E.g. like here:

* This is a headline
  Still outside the drawer
   :DRAWERNAME:
   This is inside the drawer.
   :END:
   After the drawer.
   

   =org-element-at-point= within the drawer:
(paragraph
 (:begin 65 :end 95 :contents-begin 65 :contents-end 95 :post-blank 0 
:post-affiliated 65 :parent
 (drawer
 (:begin 49 :end 104 :drawer-name "DRAWERNAME" :contents-begin 65 
:contents-end 95 :post-blank 0 :post-affiliated 49 :parent nil


-- 
Together we'll stand, divided we'll fall




Re: [O] Use org-element to figure out if I am in a drawer.

2013-11-26 Thread Nick Dokos
Carsten Dominik  writes:


> what is the magic incantation to use org-element to figure out if
> point is currently inside a drawer?
>

(eq 'drawer (org-element-type (org-element-at-point)))

is my (untested) guess, but I don't think you can be at an arbitrary
place inside: you'll need to be on the :DRAWER: line or on the :END:
line, otherwise you'll get the type of the drawer contents.

Nick




[O] Use org-element to figure out if I am in a drawer.

2013-11-26 Thread Carsten Dominik
Hmmm,

what is the magic incantation to use org-element to figure out if point is 
currently inside a drawer?

Thanks

- Carsten