abhi's logbook

Adventures in coding and coding for adventures.

Code to Update Reminders app from Emacs

(defun ay/org-update-reminder-lists ()
  (interactive)
  (ay/org-update-buy-list)
  (ay/org-update-corrie-list)
  (ay/org-update-home-list))

(defun ay/org-update-morning-list ()
  (interactive)
  (ns-do-applescript
   (concat
    "tell application \"Reminders\"\n"
    "tell list \"Morning\" to delete reminders\n"
    "tell list \"Morning\"\n"
    (mapconcat (lambda (title) (format "make new reminder with properties {name:\"%s\"}" title))
               (org-map-entries (lambda () (nth 4 (org-heading-components)))
                                "morning+TODO=\"NEXT-ACTION\"" 'agenda) "\n")
    "\nend tell\n"
    "end tell\n")))

(defun ay/org-update-reading-list ()
  (interactive)
  (ns-do-applescript
   (concat
    "tell application \"Reminders\"\n"
    "tell list \"Reading\" to delete reminders\n"
    "tell list \"Reading\"\n"
    (mapconcat (lambda (title) (format "make new reminder with properties {name:\"%s\"}" title))
               (org-map-entries (lambda () (nth 4 (org-heading-components)))
                                "reading" 'agenda) "\n")
    "\nend tell\n"
    "end tell\n")))

(defun ay/org-update-buy-list ()
  (interactive)
  (ns-do-applescript
   (concat
    "tell application \"Reminders\"\n"
    "tell list \"Buy\" to delete reminders\n"
    "tell list \"Buy\"\n"
    (mapconcat (lambda (title) (format "make new reminder with properties {name:\"%s\"}" title))
               (org-map-entries (lambda () (nth 4 (org-heading-components)))
                                "buy+TODO=\"NEXT-ACTION\"" 'agenda) "\n")
    "\nend tell\n"
    "end tell\n")))

(defun ay/org-update-corrie-list ()
  (interactive)
  (ns-do-applescript
   (concat
    "tell application \"Reminders\"\n"
    "tell list \"Corrie\" to delete reminders\n"
    "tell list \"Corrie\"\n"
    (mapconcat (lambda (title) (format "make new reminder with properties {name:\"%s\"}" title))
               (org-map-entries (lambda () (nth 4 (org-heading-components)))
                                "corrie+TODO=\"NEXT-ACTION\"" 'agenda) "\n")
    "\nend tell\n"
    "end tell\n")))

(defun ay/org-update-home-list ()
  (interactive)
  (ns-do-applescript
   (concat
    "tell application \"Reminders\"\n"
    "tell list \"Home\" to delete reminders\n"
    "tell list \"Home\"\n"
    (mapconcat (lambda (title)
                 (format "make new reminder with properties {name:\"%s\"}" title))
               (org-map-entries (lambda () (nth 4 (org-heading-components)))
                                "home" 'agenda) "\n")
    "\nend tell\n"
    "end tell\n")))