From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuchen Pei Newsgroups: gmane.emacs.bugs Subject: bug#50195: [PATCH] Adding diary-offset, a diary-sexp offsetting another diary-sexp. Date: Wed, 25 Aug 2021 13:46:48 +1000 Message-ID: <87fsuychjr.fsf@ypei.me> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22271"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.13; emacs 27.2 To: 50195@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 25 07:57:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mIluQ-0005X4-Ob for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Aug 2021 07:57:11 +0200 Original-Received: from localhost ([::1]:38790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIluP-0000Ut-9e for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Aug 2021 01:57:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIluI-0000Uk-FS for bug-gnu-emacs@gnu.org; Wed, 25 Aug 2021 01:57:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIluI-0003tP-8S for bug-gnu-emacs@gnu.org; Wed, 25 Aug 2021 01:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mIluI-0000vL-3t for bug-gnu-emacs@gnu.org; Wed, 25 Aug 2021 01:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuchen Pei Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Aug 2021 05:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50195 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.16298709693471 (code B ref -1); Wed, 25 Aug 2021 05:57:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Aug 2021 05:56:09 +0000 Original-Received: from localhost ([127.0.0.1]:45447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mIltP-0000tu-Sa for submit@debbugs.gnu.org; Wed, 25 Aug 2021 01:56:08 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mIjsS-0005wX-BA for submit@debbugs.gnu.org; Tue, 24 Aug 2021 23:47:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIjsQ-0005IL-1U for bug-gnu-emacs@gnu.org; Tue, 24 Aug 2021 23:46:58 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:39845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIjsO-0002iM-1K for bug-gnu-emacs@gnu.org; Tue, 24 Aug 2021 23:46:57 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 481285C0194 for ; Tue, 24 Aug 2021 23:46:54 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 24 Aug 2021 23:46:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ypei.me; h=from :to:subject:date:message-id:mime-version:content-type; s=fm2; bh=uYzacf65fwZOw/NCvQdND4fgHpyX4o51wlorSvXsm3I=; b=BPMxVQZGQeQq K6NMs6cg2hO1By+J0Ubvr1OQTFCK3vTGh5b2MjVe54k64ytC4PHbYyLvy9PWcrL1 UZl6uSlkftitLfWpTTLSdPMaK7AfNiV9GrMeNWjQcd/GIJ1F1KAIGipTK1LU2yip rrUfCVDf8Ne9zRHKjXMGBz1bGQWgMG1YMEhS8bJs0tFSg9p+FC5Az6B7i0txMYZ+ aklHLqJndCvA7D/2zcRWjDmeY9vBVC/6kNUXSHVfQdNp/XDFsCXAOrm8rlKZ2grb 90fuYioIdGRZ5X/mDny02ZLPoOreoQQxSoplfUnZt79Dbg9VXrXMNAD/cLanbvv8 J1/1Qkg3+A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=uYzacf65fwZOw/NCvQdND4fgHpyX4 o51wlorSvXsm3I=; b=sXMk65QnmLNGUrHC38oCwscinsiUPALZlx1nj2JTKGpDL dxs26In1ztUw3cFRjDQEPrMjVBVzda03fo/0UNwNtfFg2UQ0Wdq+oiJBdTLXIbQd UZXjK8QIPx1NHYyI9zfF0+cy5ZdS89JhzLvfybbjOQCTyaocmBdFAIum6hB7Wd9D PDX8f8sFIItYn3+VM+/lCYWH3p6V6H8FKXxNMEcqwI80vV+mXF0sJPWbRNYKY733 S9+3Ht5l4dse+K6oEQqQR9x4TNoSE5R9XFs8gtEm+3xJzcPgpdWdtxcVdDpU+4oa 3yRb6M/E/ZIiAu8/pWCwl49POTIJxL9Z1Udce+g2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtkedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegfhffvufffkfggtgesghdtreertd ertdenucfhrhhomhepjghutghhvghnucfrvghiuceohhhiseihphgvihdrmhgvqeenucgg tffrrghtthgvrhhnpedtkeevfeetgefgueffueegfeelieekudduuddukefggfeuleffhf ejiefgfedukeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehhiheshihpvghirdhmvg X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 24 Aug 2021 23:46:52 -0400 (EDT) Received-SPF: pass client-ip=66.111.4.26; envelope-from=hi@ypei.me; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 25 Aug 2021 01:56:05 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:212583 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; format=flowed Hello, See below my first patch to Emacs. The copyright assignment has already been done BTW. Let me know what you think. Would you like me to add some tests? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Adding-diary-offset-a-diary-sexp-offsetting-another-.patch Content-Transfer-Encoding: quoted-printable Content-Description: the patch From=20d385b1bc02f2922fbff4496f81d4574d0abcf082 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 25 Aug 2021 13:37:20 +1000 Subject: [PATCH] Adding diary-offset, a diary-sexp offsetting another diary-sexp. A bit like diary-remind, as a diary-sexp rather than reminder, and also support both positive and negative offsets. This is useful when for example your organization has a committee meeting two days after every monthly meeting which takes place on the third Thursday, or if you would like to attend a virtual meeting scheduled in a different timezone causing a difference in the date. =2D-- doc/emacs/calendar.texi | 14 ++++++++++++++ lisp/calendar/diary-lib.el | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi index 3750e78e70..44766c92de 100644 =2D-- a/doc/emacs/calendar.texi +++ b/doc/emacs/calendar.texi @@ -1363,6 +1363,20 @@ Special Diary Entries Thursday of January, February, and March. If the month is @code{t}, the entry applies to all months of the year. =20 +@findex diary-offset +@example +%%(diary-offset '(diary-float t 3 4) 2) Monthly post-event committee meeti= ng +@end example + +@noindent +This entry applies to the Saturday after the third Thursday of each +month. The 2 specifies number of days after when the sexp +@samp{'(diary-float t 3 4)} would evaluate to @code{t}. This is +useful when for example your organization has a committee meeting two +days after every monthly meeting which takes place on the third +Thursday, or if you would like to attend a virtual meeting scheduled +in a different timezone causing a difference in the date. + Each of the standard sexp diary entries takes an optional parameter specifying the name of a face or a single-character string to use when marking the entry in the calendar. Most generally, sexp diary entries diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index f57fe26058..d83a60680f 100644 =2D-- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -2014,6 +2014,17 @@ diary-cyclic (and (>=3D diff 0) (zerop (% diff n)) (cons mark (format entry cycle (diary-ordinal-suffix cycle)))))) =20 +;; To be called from diary-sexp-entry, where DATE, ENTRY are bound. +(defun diary-offset (sexp days) + "Offsetted diary entry. +Entry applies if the date is DAYS days after another diary-sexp SEXP." + (with-no-warnings (defvar date) (defvar entry)) + (integerp days) + (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 entr= y." (with-no-warnings (defvar date)) =2D-=20 2.33.0 --=-=-= Content-Type: text/plain; format=flowed -- Best, Yuchen PGP Key: 47F9 D050 1E11 8879 9040 4941 2126 7E93 EF86 DFD0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIEEARYIACkWIQRH+dBQHhGIeZBASUEhJn6T74bf0AUCYSW9KAscaGlAeXBlaS5t ZQAKCRAhJn6T74bf0JT9AP9UEdlRQiZAk+qf5qN6FAqS+mRfJaH2UmK1EvugkQzI ogEA2LBVAIN7KF1xaLTEUNKQsbzkXFQQ1HEg33+o69AjBAw= =0z74 -----END PGP SIGNATURE----- --==-=-=--