emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* get all todo items as lisp list
@ 2012-02-18 17:41 Peter Münster
  2012-02-19  0:28 ` Eric Abrahamsen
  2012-02-19  5:01 ` Jambunathan K
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Münster @ 2012-02-18 17:41 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Given a todo list in an org file, is there already a function, that
converts this list to an elisp list, that contains at least heading,
deadline and properties?

Example input:
--8<---------------cut here---------------start------------->8---
* TODO todo-test
  DEADLINE: <2012-04-19 Thu 13:33>
   :PROPERTIES:
   :notify:   notify-test
   :END:
* TODO todo-test2
  DEADLINE: <2012-05-20 Sun 16:66>
   :PROPERTIES:
   :notify:   notify-test2
   :END:
--8<---------------cut here---------------end--------------->8---

Example output:
--8<---------------cut here---------------start------------->8---
((file "test.org" heading "TODO todo-test" deadline (111 222 333)
       properties (notify notify-test))
 (file "test.org" heading "TODO todo-test2" deadline (123 456 789)
       properties (notify notify-test2)))
--8<---------------cut here---------------end--------------->8---

Or are there functions, that could help me, to do it myself?
(I've tried with `org-agenda-get-day-entries', but without success...)

TIA for any help!
-- 
           Peter

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

* Re: get all todo items as lisp list
  2012-02-18 17:41 get all todo items as lisp list Peter Münster
@ 2012-02-19  0:28 ` Eric Abrahamsen
  2012-02-19  5:01 ` Jambunathan K
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Abrahamsen @ 2012-02-19  0:28 UTC (permalink / raw)
  To: emacs-orgmode

On Sun, Feb 19 2012, Peter Münster wrote:

> Hi,
>
> Given a todo list in an org file, is there already a function, that
> converts this list to an elisp list, that contains at least heading,
> deadline and properties?
>
> Example input:
> * TODO todo-test
>   DEADLINE: <2012-04-19 Thu 13:33>
>    :PROPERTIES:
>    :notify:   notify-test
>    :END:
> * TODO todo-test2
>   DEADLINE: <2012-05-20 Sun 16:66>
>    :PROPERTIES:
>    :notify:   notify-test2
>    :END:
>
> Example output:
> ((file "test.org" heading "TODO todo-test" deadline (111 222 333)
>        properties (notify notify-test))
>  (file "test.org" heading "TODO todo-test2" deadline (123 456 789)
>        properties (notify notify-test2)))
>
> Or are there functions, that could help me, to do it myself?
> (I've tried with `org-agenda-get-day-entries', but without success...)

Hi,

If you load org-element.el from contrib/, I think the function
`org-element-parse-buffer' does what you want (and probably a whole lot
more).

Eric

-- 
GNU Emacs 24.0.93.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-02-16 on pellet
Org-mode version 7.8.03 (release_7.8.03.362.g1cc2)

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

* Re: get all todo items as lisp list
  2012-02-18 17:41 get all todo items as lisp list Peter Münster
  2012-02-19  0:28 ` Eric Abrahamsen
@ 2012-02-19  5:01 ` Jambunathan K
  2012-02-19 10:57   ` Nicolas Goaziou
  1 sibling, 1 reply; 4+ messages in thread
From: Jambunathan K @ 2012-02-19  5:01 UTC (permalink / raw)
  To: Peter Münster; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 807 bytes --]


> Hi,
>
> Given a todo list in an org file, is there already a function, that
> converts this list to an elisp list, that contains at least heading,
> deadline and properties?

Create the following interactive function. This functions exports Org
file to a *pretty* lisp file.

--8<---------------cut here---------------start------------->8---
(defun org-export-as-lisp ()
  (interactive)
  (or (featurep 'pp) (require 'pp))
  (let ((out-file
	 (concat (file-name-sans-extension (buffer-file-name)) ".el")))
    (pp-display-expression (org-element-parse-buffer) "*Org Data*")
    (with-current-buffer "*Org Data*"
      (write-file out-file nil))))
--8<---------------cut here---------------end--------------->8---



I am attaching sample todo.org and and the todo.el file created by the
above command.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: todo.org --]
[-- Type: text/x-org, Size: 210 bytes --]



* TODO todo-test
  DEADLINE: <2012-04-19 Thu 13:33>
   :PROPERTIES:
   :notify:   notify-test
   :END:
* TODO todo-test2
  DEADLINE: <2012-05-20 Sun 16:66>
   :PROPERTIES:
   :notify:   notify-test2
   :END:

[-- Attachment #3: todo.el --]
[-- Type: application/emacs-lisp, Size: 2189 bytes --]

[-- Attachment #4: Type: text/plain, Size: 409 bytes --]




> Example output:
> ((file "test.org" heading "TODO todo-test" deadline (111 222 333)
>        properties (notify notify-test))
>  (file "test.org" heading "TODO todo-test2" deadline (123 456 789)
>        properties (notify notify-test2)))
>
> Or are there functions, that could help me, to do it myself?
> (I've tried with `org-agenda-get-day-entries', but without success...)
>
> TIA for any help!

-- 

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

* Re: get all todo items as lisp list
  2012-02-19  5:01 ` Jambunathan K
@ 2012-02-19 10:57   ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2012-02-19 10:57 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Peter Münster, emacs-orgmode

Hello,

Jambunathan K <kjambunathan@gmail.com> writes:

>> Given a todo list in an org file, is there already a function, that
>> converts this list to an elisp list, that contains at least heading,
>> deadline and properties?
>
> Create the following interactive function. This functions exports Org
> file to a *pretty* lisp file.
>
> (defun org-export-as-lisp ()
>   (interactive)
>   (or (featurep 'pp) (require 'pp))
>   (let ((out-file
> 	 (concat (file-name-sans-extension (buffer-file-name)) ".el")))
>     (pp-display-expression (org-element-parse-buffer) "*Org Data*")
>     (with-current-buffer "*Org Data*"

Nice example.

Also, the OP may replace (org-element-parse-buffer) with
(org-element-parse-buffer 'headline) for quicker results, since parsed
headlines already contain all the required information.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2012-02-19 10:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-18 17:41 get all todo items as lisp list Peter Münster
2012-02-19  0:28 ` Eric Abrahamsen
2012-02-19  5:01 ` Jambunathan K
2012-02-19 10:57   ` 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).