Setting up appointment reminders in Org

Although the agenda view is very handy, it is generally not a good
idea to check the agenda view every three seconds to see if you have
upcoming appointments. You can set up Org to use the Emacs appointment
reminder system, which can pop up a reminder buffer before your
appointment or display a reminder in the modeline.

org-agenda-to-appt scans all your agenda files for appointments for today.
The code for org-agenda-to-appt can be found in org.el. It’s marked
experimental, so future versions may not include it. If you do not
have org-agenda-to-appt, add the following to your ~/.emacs:

;; Make appt aware of appointments from the agenda
(defun org-agenda-to-appt ()
  "Activate appointments found in `org-agenda-files'."
  (interactive)
  (require 'org)
  (let* ((today (org-date-to-gregorian
		 (time-to-days (current-time))))
	 (files org-agenda-files) entries file)
    (while (setq file (pop files))
      (setq entries (append entries (org-agenda-get-day-entries
				     file today :timestamp))))
    (setq entries (delq nil entries))
    (mapc (lambda(x)
	    (let* ((event (org-trim (get-text-property 1 'txt x)))
		   (time-of-day (get-text-property 1 'time-of-day x)) tod)
	      (when time-of-day
		(setq tod (number-to-string time-of-day)
		      tod (when (string-match
				  "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)" tod)
			     (concat (match-string 1 tod) ":"
				     (match-string 2 tod))))
		(if tod (appt-add tod event))))) entries)))

Load today’s appointments every time you start Emacs by adding the
following to your ~/.emacs:

(org-agenda-to-appt)

or call it interactively with M-x org-agenda-to-appt.

If you delete an appointment from your Org agenda file, the
corresponding alert is not deleted. To delete the appointment, use M-x
appt-delete and select it from the list.

A better way to keep your appointment list clean would be to remove
all the appointment entries before calling org-agenda-to-appt. Add the
following to your ~/.emacs to do so:

(defadvice org-agenda-to-appt (before wickedcool activate)
  "Clear the appt-time-msg-list."
  (setq appt-time-msg-list nil))

To learn more about configuring the Emacs appointment reminder system,
check out the Emacs manual.

On Technorati:

Random Emacs symbol: ibuffer-mode – Function: A major mode for viewing a list of buffers.

2 responses to “Setting up appointment reminders in Org”

  1. I didn’t seem to have this function in my Org made. (Emacs 22 from Debian unstable). So I tried adding it from here. It comes up with an error, however, because it can’t find org-date-to-gregorian. Google wasn’t very forthcoming on this function. Any ideas why I don’t have it?

    1. Sacha Chua says:

      You might need a newer version of Org, which you can get from orgmode.org. (Reminds me, I should try out 6.14…)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>