-- Leo's gemini proxy

-- Connecting to tilde.pink:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;

I wanted to use Emacs Calendar and Diary to mark last non holiday day in each month as a reminder to send invoice. Regular date format can't be that specific. Diary has special functions that helps with marking abstract dates but as far as my research goes It can't mark last non holiday day in month.


No hope is lost when you can write your own code. First I read very end of "the Calendar and the Diary" info page where I found secret knowledge.


(info "(emacs) Sexp Diary Entries")

Then I wrote elisp expression inside diary file:


%%(seq-let (month day year) date
    (let ((last-day (date-days-in-month year month)))
      (while (seq-contains calendar-weekend-days
                           (calendar-day-of-week (list month last-day year)))
        (setq last-day (1- last-day)))
      (if (= day last-day) '(error . "Invoice"))))

Code takes last day of given month and check if it's not a weekend day. If it is then go back by one day and check again. Repeat until you encounter regular day. Then check if given "date" match that day. If so then mark date using "error" face with "Invoice" description.


Lesson for today?


> Read documentations and live to code another day!


EOF

-- Response ended

-- Page fetched on Sun May 19 16:41:19 2024