From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Persaud Subject: 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 Message-ID: <4F53FF43.4090402@lbl.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:46496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4LAB-0001Tm-3l for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 18:48:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4LA8-0003xU-T5 for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 18:48:26 -0500 Received: from ironport4.lbl.gov ([128.3.41.45]:62582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4LA8-0003xD-JF for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 18:48:24 -0500 Received: by pbcuo15 with SMTP id uo15so844194pbc.39 for ; Sun, 04 Mar 2012 15:48:21 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 . (setq entry (plist-put entry :link (xml-get-attribute (car (xml-get-children xml 'link)) 'href))) ;; Add 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)