emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Use org-element to figure out if I am in a drawer.
@ 2013-11-26 15:24 Carsten Dominik
  2013-11-26 15:41 ` Nick Dokos
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Carsten Dominik @ 2013-11-26 15:24 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org List

Hmmm,

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

Thanks

- Carsten

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

* Re: Use org-element to figure out if I am in a drawer.
  2013-11-26 15:24 Use org-element to figure out if I am in a drawer Carsten Dominik
@ 2013-11-26 15:41 ` Nick Dokos
  2013-11-26 15:49 ` Rasmus
  2013-11-26 16:32 ` Nicolas Goaziou
  2 siblings, 0 replies; 4+ messages in thread
From: Nick Dokos @ 2013-11-26 15:41 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> 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

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

* Re: Use org-element to figure out if I am in a drawer.
  2013-11-26 15:24 Use org-element to figure out if I am in a drawer Carsten Dominik
  2013-11-26 15:41 ` Nick Dokos
@ 2013-11-26 15:49 ` Rasmus
  2013-11-26 16:32 ` Nicolas Goaziou
  2 siblings, 0 replies; 4+ messages in thread
From: Rasmus @ 2013-11-26 15:49 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> 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

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

* Re: Use org-element to figure out if I am in a drawer.
  2013-11-26 15:24 Use org-element to figure out if I am in a drawer Carsten Dominik
  2013-11-26 15:41 ` Nick Dokos
  2013-11-26 15:49 ` Rasmus
@ 2013-11-26 16:32 ` Nicolas Goaziou
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2013-11-26 16:32 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode@gnu.org List

Hello,

Carsten Dominik <carsten.dominik@gmail.com> 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

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

end of thread, other threads:[~2013-11-26 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 15:24 Use org-element to figure out if I am in a drawer Carsten Dominik
2013-11-26 15:41 ` Nick Dokos
2013-11-26 15:49 ` Rasmus
2013-11-26 16:32 ` Nicolas Goaziou

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