summaryrefslogtreecommitdiff
path: root/lisp/calendar
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2021-09-04 08:28:57 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-09-04 09:12:10 +0200
commitca7e76c6f98cb09a686bcda7890ca10fd374fb4f (patch)
treeca1beeb29d8ee1240da5ddbff423dd68df8670ce /lisp/calendar
parentf9dcde3906b9c764b794d580d4d24691979f7d81 (diff)
downloademacs-ca7e76c6f98cb09a686bcda7890ca10fd374fb4f.tar.gz
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).
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/diary-lib.el11
1 files changed, 11 insertions, 0 deletions
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))