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 to diary-lib.el Date: Thu, 26 Aug 2021 16:49:29 +1000 Message-ID: <87mtp4bszq.fsf@ypei.me> References: <87fsuychjr.fsf@ypei.me> <83mtp5vizs.fsf@gnu.org> 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="26930"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.13; emacs 27.2 Cc: 50195@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 26 08:50:29 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 1mJ9DY-0006l7-E0 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 08:50:29 +0200 Original-Received: from localhost ([::1]:49892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJ9DW-0006qx-Sy for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 02:50:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJ9D8-0006qe-IZ for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 02:50:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJ9D8-0004vv-Ag for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 02:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJ9D8-0000fS-8e for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 02:50: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: Thu, 26 Aug 2021 06:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50195 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 50195-submit@debbugs.gnu.org id=B50195.16299605872486 (code B ref 50195); Thu, 26 Aug 2021 06:50:02 +0000 Original-Received: (at 50195) by debbugs.gnu.org; 26 Aug 2021 06:49:47 +0000 Original-Received: from localhost ([127.0.0.1]:48223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJ9Cs-0000e2-Lj for submit@debbugs.gnu.org; Thu, 26 Aug 2021 02:49:46 -0400 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33981) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJ9Cp-0000dM-L1 for 50195@debbugs.gnu.org; Thu, 26 Aug 2021 02:49:45 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 63C2D3200924; Thu, 26 Aug 2021 02:49:37 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 26 Aug 2021 02:49:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ypei.me; h= references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=fm2; bh=mw6rNNhR/+doW7Qmql4uoqiU4y rqm6MPvZOF4Yaupr0=; b=cXcWo2fDwCTBJU34z2YUlvK3Y1SKmfHwHdbsTkYZGj HrtsoI6+tseod2y0egOK9rczBiBWQBirfS1zTlNfw/LmHVwfBEqMO2b88wza02Yv 31HuBJq6BZToZAmdG4O59AyuTAJV4uLZFnCbPrI2RJ9nBqxCv6hz1JZVNzPEKnJX WHC6ugfeuybw8euLMA2iigT4SIDYaDKYvYUvJY0ElmRAOR8xmKAeIF1toKY5EOVa Eh7uQ6yfWu6ixe3Oaglx7Pto0ZnDkmRDkXYu62/fUvQJlKDqX2zE7RZ3HAjrPdG2 14jHmeXlbd9G9U0KPwk7HbQIwnAOGCw/z9QWjDgaGWuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=mw6rNN hR/+doW7Qmql4uoqiU4yrqm6MPvZOF4Yaupr0=; b=eOB87yq34KKtRrLg7jVmB8 0LSdm48m5hfjmqktMTj27ySgexH3/iURQ3UBXRcmlDBJ4BCOrOOoj5HNUj85vWXL EA7ir9J99xjAiLZxkRfWntF9d8AQ5RVVNjcju+8XqNL+GYjT54qXWe818Dne6Vcn ocpyQX/tKlW8CXEKTF0hL3i1gVfWbkw25swMa52le1EsW4PUFeyfipcjUT0KCImA Qc5bockYXVQeFVExBaIE60HTdClLVFP+yZ1gF/6uSijU0Gnv2TTQMpnGWWHaxIuM 2bn3tTOf+mh7bWYdrEoEG5Je5selcsr3qwmHyQQwN3ituNu7SQi10qxf3g98/0sQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddutddgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvffujgffkfggtgesghdtreertdertdenucfhrhhomhepjghutghh vghnucfrvghiuceohhhiseihphgvihdrmhgvqeenucggtffrrghtthgvrhhnpeektdffhf eliefgheeuveeiueeukedvgfevgeehieduueffvdfgjeelieejveehteenucffohhmrghi nhephihpvghirdhmvgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehhiheshihpvghirdhmvg X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Aug 2021 02:49:35 -0400 (EDT) In-reply-to: <83mtp5vizs.fsf@gnu.org> 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:212690 Archived-At: --=-=-= Content-Type: text/plain; format=flowed Thanks for the comments. Eli Zaretskii writes: >> From: Yuchen Pei >> Date: Wed, 25 Aug 2021 13:46:48 +1000 >> >> See below my first patch to Emacs. The copyright assignment >> has >> already been done BTW. > > Congrats, and welcome aboard. > >> Let me know what you think. > > Some minor comments below. > >> Would you like me to add some tests? > > Adding more tests is always welcome, thanks. All diary sexp tests are in icalendar tests, but diary-offset does not easily translate to icalendar events (exporting to icalendar for this sexp is rather complicated if not impossible as it applies on top of another arbitrary sexp), so I am just adding a simple no-op-like test. > >> Subject: [PATCH] Adding diary-offset, a diary-sexp offsetting >> another >> diary-sexp. > > "git am" uses the Subject for the heading line, and this Subject > is > too long for that. Please consider making it shorter. Done. > >> 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. > > The commit log message should include a ChangeLog-style > description of > the files and functions where you made the changes. See > CONTRIBUTE > for more details about the format we prefer. > > Also, please in the next version include the bug number as part > of the > log message. Done. > >> --- 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. >> >> +@findex diary-offset >> +@example >> +%%(diary-offset '(diary-float t 3 4) 2) Monthly post-event >> committee meeting > > That line is too long, and will overflow the page width in the > printed > version of the manual. Please break it in two. Done. I made it shorter :) > >> +@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 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This should be in @code, not @samp. I'd also wrap it in @w{..}, > so > that it doesn't get broken between two lines. Done. > >> +(defun diary-offset (sexp days) >> + "Offsetted diary entry. > > The first line of a doc string should preferably mention the > arguments, but without becoming too long, so it could still fit > on a > single line. Done. > >> + (with-no-warnings (defvar date) (defvar entry)) > > Why did you need this? The sexp diary-offset itself requires the date supplied by diary-sexp-entry. The sexp passed to diary-offset will ask for both date and entry. Removed (defvar entry) as this is not needed by diary-offset. After the removel I tested it in org mode and org agenda and it works. > >> + (integerp days) > > Isn't it better to use an assertion? Done. Added a user-error statement like in diary-cyclic. > > Thanks. -- 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+dBQHhGIeZBASUEhJn6T74bf0AUCYSc5eQscaGlAeXBlaS5t ZQAKCRAhJn6T74bf0OEmAQDbDOE2DIGmKzZr7hXzCFI9FTlEpcd9KaKDqXJBLFOj IAEA0H/5kD0cIvm+QJFFPU3edNA2Ecb2G8/FJAauOAnupAc= =Xil4 -----END PGP SIGNATURE----- --=-=-=--