1 ;;; org2rem.el --- Convert org appointments into reminders
3 ;; Copyright 2006 Bastien Guerry
5 ;; Author: bzg AT altern DOT fr
6 ;; Version: $Id: org2rem.el,v 0.1 2006/12/04 09:21:03 guerry Exp guerry $
7 ;; Keywords: org-mode remind reminder appointment diary calendar
8 ;; X-URL: http://www.cognition.ens.fr/~guerry/u/org2rem.el
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; if not, write to the Free Software
22 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Not so much to say here. Just try org2rem in your org-mode buffer.
28 ;; Put this file into your load-path and the following into your ~/.emacs:
37 (defvar org2rem-scheduled-reminders nil
)
38 (defvar org2rem-deadline-reminders nil
)
39 (defvar org2rem-scheduled-remind-file
40 "~/.reminders.org.scheduled")
41 (defvar org2rem-deadline-remind-file
42 "~/.reminders.org.deadline")
44 (defun org2rem-list-reminders (regexp)
45 "Make a list of appointments.
46 REGEXP is either SCHEDULED: or DEADLINE:."
48 (goto-char (point-min))
49 (while (re-search-forward
50 (concat "^[ \t]*" regexp
51 "[ \t]*" org-ts-regexp2
) nil t
)
52 (let* ((system-time-locale "C") ;; make sure we use english dates
53 (year (string-to-number (match-string-no-properties 2)))
54 (month (string-to-number (match-string-no-properties 3)))
55 (day (string-to-number (match-string-no-properties 4)))
56 (encoded-time (encode-time 0 0 0 day month year
))
57 (rem-time (format-time-string " %d %b %Y " encoded-time
))
60 (re-search-backward org-todo-line-regexp nil t
)
62 (replace-regexp-in-string
63 org-bracket-link-regexp
64 "\\3" (match-string-no-properties 3)))
65 (setq rem-task
(concat "REM" rem-time
"MSG " task
"%"))
66 (if (equal regexp org-scheduled-string
)
67 (push rem-task org2rem-scheduled-reminders
)
68 (push rem-task org2rem-deadline-reminders
)))))))
70 (defun org2rem-write-file (file reminders
)
71 "Write reminders list to files."
75 (dolist (rem reminders
)
78 (kill-buffer (file-name-nondirectory file
))))
81 "Convert apptointment from local org-mode buffer to reminders.
82 Store scheduled appointments in `org2rem-scheduled-remind-file'
83 and `org2rem-deadline-remind-file'."
85 (setq org2rem-scheduled-reminders nil
)
86 (setq org2rem-deadline-reminders nil
)
87 (save-window-excursion
88 (org2rem-list-reminders org-scheduled-string
)
89 (org2rem-list-reminders org-deadline-string
)
90 (org2rem-write-file "~/.reminders.org.scheduled"
91 org2rem-scheduled-reminders
)
92 (org2rem-write-file "~/.reminders.org.deadline"
93 org2rem-deadline-reminders
)))
97 ;;;;##########################################################################
98 ;;;; User Options, Variables
99 ;;;;##########################################################################
105 ;;; org2rem.el ends here