Q: How can I make
org-read-date understand an abbreviation that calls a function that returns tomorrow's day of the week?
The super-short version: I'm trying to get the timestamp functionality of
+1d when typing
tom as a more finger-friendly way of saying "tomorrow."
I'm trying to train
org-read-date to understand new, easier-to-type abbreviations when I'm entering timestamps, scheduled items, and deadlines. In particular, when entering a timestamp, I'd like to be able to enter
tom and have
org-read-date recognize it as "whatever day tomorrow is" (yes, I know I can type
+1d, but it's an awfully awkward sequence of keys).
parse-time functionality on which
org-read-date relies expects an integer from 0 (Sunday) to 6 (Saturday). Fair enough, here's a little function that does it:
(defun tomorrow-day () "Returns the day of the week for tomorrow." (let ((day (1+ (string-to-number (format-time-string "%w"))))) (if (= day 7) 0 day)))
I'm stuck at the following point. Following this prior thread, I've
pushed this function onto the
(push `("tom" . ,(tomorrow-day)) parse-time-weekdays)
Here's the problem: quasi-quoting pushes the literal value that
tomorrow-day returns only at the time it was first evaluated (so, if today is Monday,
tom refers to day number 2 from here to eternity). Instead, I need
tomorrow-day evaluated each time I invoke
tom when entering a timestamp. Why? Because I commonly leave an Emacs session running for days at a time, meaning that
tom no longer refers to "tomorrow" after the day on which it was evaluated.
I've tried various forms of quoting and quasi-quoting, and eventually got quite silly with an intricate combination of
evals, all to no avail.
So: how do I get this function (
tomorrow-day) evaluated every time I enter
tom in a timestamp?