News for hackers. Stuff that matters.
Re:Org-Mode Is One of the Most Reasonable Markup Languages t... by jolmg on Wednesday April 10, 2019 @03:59PM (#19628231)
I was wondering just a while ago if it those diary syntaxes were really limited to sexps and wouldn't also evaluate arbitrary elisp and I saw this[1]:

  &%%(let ((dayname (calendar-day-of-week date))
           (day (cadr date)))
        (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
            (and (memq day '(19 20)) (= dayname 5)))
           ) Pay check deposited
I don't know if this is doable from org-mode but it seems to me like this could be a viable, more readable alternative to diary-float.

For your example of 2nd Thursday from every month, instead of:

  %%(dairy-float t 4 2)
you could have:

  &%%(let ((day-of-week (calendar-day-name date))
           (day (cadr date)))
       (and (= day-of-week "Thursday")
            (> day 7)
            (<= day 14)))
That's seems more readable to someone that hasn't read what the parameters of dairy-float mean. For your second example of every 2nd and 4th Thursday:

  &%%(let ((day-of-week (calendar-day-name date))
           (day (cadr date)))
       (and (= day-of-week "Thursday")
            (or (and (> day 7) (<= day 14))
                (and (> day 21) (<= day 28)))))
It being a programming language might make it unintuitive to use by a non-programmer, but I don't think you can get anymore flexible than this. Also, org-mode's attractiveness being that everything is in plain text, I'm not sure there is a syntax that would be more readable than properly written code.

[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Se...

There are no comments on this comment yet.