[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] my setup for "remember the milk" (one way import to org-mode via org
From: |
Arun Persaud |
Subject: |
[O] my setup for "remember the milk" (one way import to org-mode via org-feed.el) |
Date: |
Sun, 04 Mar 2012 15:48:19 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120215 Thunderbird/10.0.2 |
Hi
I recently needed to add entries from "remember the milk"(RTM)[1] to my
org files... I found a script that converts to an orgfile[2], but also
the standard org-feed.el that can handle atom feeds. I played around a
bit with the latter and came up with the functions below that parse the
atom feed from RTM and also parse things like the due-date, tags, etc.
I also filter the feed by only including items that have a due date set
via the filter function.
Perhaps this is interesting for someone else, so I thought I post it
here. I could also upload it to Worg if there is interest, but am not
sure where it would go (don't use Worg that much lately).
cheers
Arun
[1] www.rememberthemilk.com/
[2] https://gist.github.com/1379125
; set up RTM
(defun org-feed-parse-RTM-entry (entry)
"Parse the `:item-full-text' as a sexp and create new properties."
(let ((xml (car (read-from-string (plist-get entry :item-full-text)))))
;; Get first <link href='foo'/>.
(setq entry (plist-put entry :link
(xml-get-attribute
(car (xml-get-children xml 'link))
'href)))
;; Add <title/> as :title.
(setq entry (plist-put entry :title
(xml-substitute-special
(car (xml-node-children
(car (xml-get-children xml 'title)))))))
;; look for some other information that's in the content of the entry
;; the structure looks something like:
;; <content><div> <div item> <span itemname></span><span
itemvalue></span></div>...
(let* ((content (car (xml-get-children xml 'content)))
(main (car (xml-get-children content 'div)))
(items (xml-get-children main 'div)))
(when items
; iterate over all items and check for certain classes
(while items
(setq item (car items))
; get the second span entry
(setq valuesub (car (cdr (xml-node-children item))))
(cond
((string= (xml-get-attribute item 'class) "rtm_due")
(setq entry (plist-put entry :due (car (xml-node-children
valuesub))))
(setq mydate (car (xml-node-children valuesub)))
(if (string= mydate "never")
nil
(progn
(string-match "^\\([a-zA-Z]*\\) \\([0-9]*\\) \\([a-zA-Z]*\\)
\\([0-9]*\\)$" mydate)
(setq mydate (concat "20" (match-string 4 mydate) " "
(match-string
3 mydate) " " (match-string 2 mydate) " 00:00:01"))
(setq mydate (parse-time-string mydate))
(setq mydate (apply #'encode-time mydate))
(setq mydate (format-time-string (car org-time-stamp-formats)
mydate))
(setq entry (plist-put entry :dueorgformat mydate)))))
((string= (xml-get-attribute item 'class) "rtm_tags")
(setq entry (plist-put entry :tags (car (xml-node-children
valuesub)))))
((string= (xml-get-attribute item 'class) "rtm_time_estimate")
(setq entry (plist-put entry :timeestimate (car
(xml-node-children valuesub)))))
((string= (xml-get-attribute item 'class) "rtm_priority")
(setq entry (plist-put entry :priority (car (xml-node-children
valuesub)))))
((string= (xml-get-attribute item 'class) "rtm_location")
(setq entry (plist-put entry :location (car (xml-node-children
valuesub))))))
(setq items (cdr items))
)))
entry))
(defun org-feed-RTM-filter-non-scheduled (entry)
"filter out all entries that don't have a due date set"
(if (string= (plist-get entry :due) "never")
nil
entry))
(setq org-feed-alist
'(("Remember The Milk"
"<add your link to the RTM atom feed here>"
"~/org/RTM.org"
"Remember The Milk"
:parse-feed org-feed-parse-atom-feed
:parse-entry org-feed-parse-RTM-entry
:template "* TODO %title\n SCHEDULED:%dueorgformat\n Due:
%due\n Location: %location\n Priority:%priority\n Tags:%tags\n %a\n "
:filter org-feed-RTM-filter-non-scheduled
)))
;;* rtm feed timer
(run-at-time 3600 3600 'org-feed-update-all)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [O] my setup for "remember the milk" (one way import to org-mode via org-feed.el),
Arun Persaud <=