From ca7e76c6f98cb09a686bcda7890ca10fd374fb4f Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 4 Sep 2021 08:28:57 +0200 Subject: Add diary-offset to diary-lib.el * doc/emacs/calendar.texi: Document the change. * lisp/calendar/diary-lib.el (diary-offset): * test/lisp/calendar/icalendar-tests.el: Add a test (bug#50195). --- lisp/calendar/diary-lib.el | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lisp/calendar') diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index f57fe26058f..9ca7ce3f003 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -2014,6 +2014,17 @@ string to use when highlighting the day in the calendar." (and (>= diff 0) (zerop (% diff n)) (cons mark (format entry cycle (diary-ordinal-suffix cycle)))))) +;; To be called from diary-sexp-entry, where DATE, ENTRY are bound. +(defun diary-offset (sexp days) + "Offsetted diary entry. Offsets SEXP by DAYS days. +Entry applies if the date is DAYS days after another diary-sexp SEXP." + (with-no-warnings (defvar date)) + (unless (integerp days) + (user-error "Days must be an integer")) + (let ((date (calendar-gregorian-from-absolute + (- (calendar-absolute-from-gregorian date) days)))) + (eval sexp))) + (defun diary-day-of-year () "Day of year and number of days remaining in the year of date diary entry." (with-no-warnings (defvar date)) -- cgit v1.2.1