Highlighting the current date in org-mode buffers
I like to take notes and track all sorts of things with org-mode. I usually put entries in tables like the one below:
|------------------+---------------------|
| Day | Chore |
|------------------+---------------------|
| <2022-02-16 Wed> | Take out the trash |
| <2022-02-17 Thu> | Clean the sink |
| <2022-02-18 Fri> | Clean the bathrooms |
| <2022-02-19 Sat> | Vaccuum |
| ... | ... |
When presenting data in a table like that, it isn't obvious which row corresponds to the current date. To solve that, I defined an elisp function to highlight the current date:
(defun laurent/org-time-stamp-string ()
(format-time-string "<%Y-%m-%d %a>" (current-time)))
(defun laurent/highlight-current-date ()
(interactive)
(highlight-phrase (laurent/org-time-stamp-string) 'error))
I tested it and it worked, but I wanted it to run automatically. All I have to do to achieve that was adding a comment to call it when the file opens:
# Local Variables:
# eval: (laurent/highlight-current-date)
# End:
The result looks like this, with the date in red: