Schedule Street Cleaning Reminders in Org-mode
Org-mode can parse Emacs diary entries that represent concepts such as the 4th Tuesday of the month, which makes it possible to schedule agenda reminders for periodic events like street sweeping.
For example, the diary-float
entry below represents the 4th Tuesday of each month:
- the value t is a placeholder that represents all months
- the value 2 represents Tuesday (Sunday=0, Monday=1, …, Saturday=6)
- the value 4 represents 4th
%%(diary-float t 2 4) Today is the 4th Tuesday of the month
Use two separate entries to represent both the 2nd and 4th Tuesdays of each month.
%%(diary-float t 2 2) Today is the 2nd Tuesday of the month
%%(diary-float t 2 4) Today is the 4th Tuesday of the month
To get a reminder one day ahead of time, wrap the diary-float expression with diary-remind
and specify -1 days as the last parameter.
%%(diary-remind '(diary-float t 2 4) -1) Monday before the 4th Tuesday
In my case, the city cleans the nearby blocks on the 2nd and 4th Tuesday-Friday of each month. Putting it all together, the street cleaning section of my org file looks like this when the car is parked on the Friday side of the street.
* Street Cleaning
** COMMENT Move the car before Tuesday at 10
<%%(diary-remind '(diary-float t 2 2) -1)>
<%%(diary-remind '(diary-float t 2 4) -1)>
** COMMENT Move the car before Wednesday at 11
<%%(diary-remind '(diary-float t 3 2) -1)>
<%%(diary-remind '(diary-float t 3 4) -1)>
** COMMENT Move the car before Thursday at 12
<%%(diary-remind '(diary-float t 4 2) -1)>
<%%(diary-remind '(diary-float t 4 4) -1)>
** TODO Move the car before Friday at 11
<%%(diary-remind '(diary-float t 5 2) -1)>
<%%(diary-remind '(diary-float t 5 4) -1)>
Any entry marked as a COMMENT will not appear in the agenda.
Each time the car moves to a new location, toggle the COMMENT off for the new location’s entry using Ctrl-C ;
and toggle it on for the rest of the entries using Ctrl-C ;
.
Marking the new location’s entry as TODO isn’t required, but it makes the reminder stand out more in the agenda view.
Although this approach requires one to manually toggle the COMMENT on and off to hide and show entries in the agenda, it should be possible to write custom code that combines the standard Emacs state transitions with diary entries to accomplish the same thing in a more elegant fashion.