From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id uNTaH/o8hGdJXQEA62LTzQ:P1 (envelope-from ) for ; Sun, 12 Jan 2025 22:06:50 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id uNTaH/o8hGdJXQEA62LTzQ (envelope-from ) for ; Sun, 12 Jan 2025 23:06:50 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=Jc5vWFJA; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1736719609; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DAxmc51Tso92I9V+GdFKVmE2ZTIQX3RyA2enUSq9OSw=; b=kh1q7WGePoweRkJQcHQccUjOjPgr5kxUdYmzEoXRjze+ss/Q6IddYq4CDGgWNVc+swZqr6 i4b8n4ZRtBsLF5oBBBH4FO6iJ9bTYf8gYXjEXCrKdzTOlumJvjC+y1JmddS0dyEEmBDude 38xTtS3IsvTWDyxuaH/maG2MC8pTaFNdvDSRos0aIixtHcevXPGDqZ4da0aE1egwL1IKFM 9sSh0BhnGRbYaYm1Te+kn0GWp8pPRvFEnm6/2rR5F5aPt08ZfBF6yHDCO/ztt5YByRi3cL uzwzUVoE321FQAIyB6qtLMInbkMZnMMSFVdSmeIL8eooUeGqot+2qY3fZpKvFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=Jc5vWFJA; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1736719609; a=rsa-sha256; cv=none; b=q3hNMF0Gu1pG0Qn4DIvcV7e/ZmRVXwgJ1oGTA4Tm4cH0wEtET06fUUMRhxpdP5dMllRYD/ X3OK2LCzen8EjwpEXh108Fj33GOJFF1qyVL/3zpq+lSJNzSOX8vyB5bCzm+39n6fy6FiZU LMCEYow9EeZN9M/2SvVmFtn2QNv7rKTw2IKSAx2Jox9Tu/l6tlf72DOFyJh/ygabR/VwC3 9Oj91ZgXN8Tn5mTK1a42BJQWHiM5zmDFNRwMQTxKk8DdFKLooqlkjF4yz+qYZSvzQM+Vtz 9v17bXoEvknvKLJvvQHt47fWX3Jcx2x0THfdIi7ioUPxMv353vErFE+xiT/VLw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5123B18B36 for ; Sun, 12 Jan 2025 23:06:49 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tX5cp-0001hJ-Mo; Sun, 12 Jan 2025 16:36:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tX5co-0001gi-In for emacs-orgmode@gnu.org; Sun, 12 Jan 2025 16:36:02 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tX5cm-0001kU-HK for emacs-orgmode@gnu.org; Sun, 12 Jan 2025 16:36:02 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-216426b0865so61844415ad.0 for ; Sun, 12 Jan 2025 13:35:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736717759; x=1737322559; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=p+TMjwD/EbznVhm9rqRpNXG8CtfXBos5V2HGiIpVwqQ=; b=Jc5vWFJAlwor3QLTkpd3vOlGXI9r2WzXj9GmELOp5Nxm8o4qqsu6F185XZfhG98QS/ 26i9BinN38ZtI2Q8lLVkN+F+L5G5b66tu0GnbmXHDdF9nEBAtV2KGBv3faFEh9fusiOa X3ZtaP6ohftz3/4FO8iJCtQC3wD08mNOVC4ZCy4wDfUmJQZWtb5muJ4JFYk5iVkfo08U IPvAXEJtEtnE7cNpcGh8O0hKWnUXxZvX2o+qJUaqhFAIf5ac13J7WA1RrhdWdT/exLPJ IdmbHspH4AgltBicgvMW8Oe0repGkvpjFwMj/Q75wtk2r9Hx5rFNa2GDnJRHnoLKSf63 djxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736717759; x=1737322559; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p+TMjwD/EbznVhm9rqRpNXG8CtfXBos5V2HGiIpVwqQ=; b=DQ3+1H8DJqh6it55nfbbIrXshFE/83k3Ng1tot5fVZzeqHLnstUWJS6w80pwj+ra3N nC+tU9cvHiEVN7itDgKJ8xfdsH6BIlidHWHLc+Ip6rKw2jXaWPSjSSwnN6A5+Nsu78aH sYV8xpEY01swhlA1cPDQ3VmMmFQ3TyWVy7ngjuFc8gVPNbFhRxuSQCl4NMrQdwtqgINA Sd+QNfvQn6Vlx4ThbjdMUZIFJBKNvGbwiSnoRjlOgvMkvHfFwEvfMbyb4UDNKox3RMK9 IYTJ0NnTbU9Kbwq9obrojUEqQWlLnBn+DAXVgbRP89NOwq4YgTauEMjqfKvg4X1BwJRK 8h3Q== X-Gm-Message-State: AOJu0Yxzg9CPGAUCKaqPafJk5Lj+lhbECkctN10KxdgK4pxCsfdwyPW8 pr4qFLjXSWayMpVWusZAyYyLBeOeanHbKKG9YTOsFVUxT5FlQzc7/Gen3A== X-Gm-Gg: ASbGncuCSNlQwMNNFgaFcBeE7Qt1AKbdkrQZP/4wN/kBPeeoNwAolDOzfwv4OSm3o8b aOfguZkX/cMV7ZdyYadGxnkpwmqR8mPof/dKkzCk3/XK7pf2iZdtwcSFAHlwdg9rE44iPIbRX/3 Pww8rPQSNOvekcYx21ovAdNaeEKs2WM+6oUr6JIlPiK3PE/cmN8WTip4WDvsidh2xlRcvFnVktW vBhEFLmCFW+vD+RLsK57kNtwjHqTdfiEJdKamC8GZjxvO9z/M9pe6wwPD2J8ueNheDEwlAqA5NB 8Gcf0rYyts7S25st5As= X-Google-Smtp-Source: AGHT+IGMEZIxbYW9s+ktAmPzswjXkgFzxJKCJPu9HVx2Ap4e26gpr4Y/K9us2wLXfJFQFYv64DlDgQ== X-Received: by 2002:a17:903:2b03:b0:216:2f7f:ff69 with SMTP id d9443c01a7336-21a83f36d33mr301568935ad.5.1736717758898; Sun, 12 Jan 2025 13:35:58 -0800 (PST) Received: from localhost (157-131-77-158.fiber.dynamic.sonic.net. [157.131.77.158]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f53eeee106sm5547960a91.1.2025.01.12.13.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2025 13:35:58 -0800 (PST) From: Jack Kamm To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Fix ox-icalendar export of diary timestamps In-Reply-To: <87r09cq92t.fsf@localhost> References: <87y13tqvpd.fsf@gmail.com> <875xqppeur.fsf@localhost> <87v7yorhq4.fsf@gmail.com> <87r09cq92t.fsf@localhost> Date: Sun, 12 Jan 2025 13:35:57 -0800 Message-ID: <87h663pveq.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=jackkamm@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 3.24 X-Spam-Score: 3.24 X-Migadu-Queue-Id: 5123B18B36 X-Migadu-Scanner: mx10.migadu.com X-TUID: 72lztZppbpil --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Jack Kamm writes: > >> Ihor Radchenko writes: >> >>> I agree that it makes sense. >>> However, it is technically a breaking change. >>> May you please add a news entry as well? >> >> Thanks, I've updated the patch with a news entry now. > > Thanks! > Applied, onto main. > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c07028671d Hi, revisiting this old thread. Unfortunately I found a case in the wild where this change caused a temporary problem in org-caldav: https://github.com/dengste/org-caldav/issues/315 I was able to fix the problem on org-caldav side, but it made me think that I should have added an option to keep the old behavior (export active timestamps excluding diary timestamps). I attach a patch to do this, by adding an option `active-exclude-diary' for `org-icalendar-with-timestamps' and `org-export-with-timestamps'. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-export-icalendar-with-timestamps-active-exclude-.patch >From d0b6c661528c5d7ae0f7fb3d393797aad2a291f8 Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Sun, 12 Jan 2025 13:10:34 -0800 Subject: [PATCH] org-(export,icalendar)-with-timestamps: active-exclude-diary option * lisp/ox.el (org-export-with-timestamps): Add option `active-exclude-diary' to export active timestamps without diary timestamps. (org-export--skip-p): Use new helper function `org-export--skip-timestamp-p'. (org-export--skip-timestamp-p): Helper function to decide whether to skip a timestamp during export * lisp/ox-icalendar.el (org-icalendar-with-timestamps): Add option `active-exclude-diary' to export active timestamps without diary timestamps. (org-icalendar-entry): Use new helper function `org-export--skip-timestamp-p' to decide whether to skip a timestamp. * testing/lisp/test-ox-icalendar.el (test-ox-icalendar/exclude-diary-timestamp): Test that diary timestamp is excluded when `active-exclude-diary'. --- etc/ORG-NEWS | 4 ++++ lisp/ox-icalendar.el | 29 ++++++++++++++--------- lisp/ox.el | 39 ++++++++++++++++++++----------- testing/lisp/test-ox-icalendar.el | 15 ++++++++++++ 4 files changed, 63 insertions(+), 24 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index aebd0dedd..3b86ece18 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -100,6 +100,10 @@ This should have minimal impact on non-iCalendar exporters, since users who manually set ~org-export-with-timestamps~ to ~active~ will now have diary timestamps included as well. +To export active timestamps only without diary timestamps, users can +set ~org-export-with-timestamps~ and ~org-icalendar-with-timestamps~ +to ~active-exclude-diary~. + *** =ob-calc.el=: Vector and matrix are now inserted as Org tables by default ~ob-calc~ now formats vector and matrix results as Org tables. This diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index bb01f1a22..da6339381 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -202,18 +202,27 @@ (defcustom org-icalendar-categories '(local-tags category) (defcustom org-icalendar-with-timestamps 'active "Non-nil means make an event from plain time stamps. -It can be set to `active', `inactive', t or nil, in order to make -an event from, respectively, only active timestamps, only -inactive ones, all of them or none. +It can be set to `active', `active-exclude-diary', `inactive', t +or nil, in order to make an event from, respectively, only active +timestamps (with/without diary timestamps), only inactive ones, +all of them or none. + +This variable has the same options as +`org-export-with-timestamps', and takes precedence over it. +However, note that this variable applies to all timestamps within +an entry, whereas `org-export-with-timestamps' only applies to +timestamps isolated in a paragraph containing only timestamps. -This variable has precedence over `org-export-with-timestamps'. It can also be set with the #+OPTIONS line, e.g. \"<:t\"." :group 'org-export-icalendar :type '(choice (const :tag "All timestamps" t) - (const :tag "Only active timestamps" active) + (const :tag "Active timestamps, including diary timestamps" active) + (const :tag "Active timestamps, excluding diary timestamps" + active-exclude-diary) (const :tag "Only inactive timestamps" inactive) - (const :tag "No timestamp" nil))) + (const :tag "No timestamp" nil)) + :safe (lambda (x) (memq x '(t nil active active-exclude-diary inactive)))) (defcustom org-icalendar-include-todo nil "Non-nil means create VTODO components from TODO items. @@ -744,11 +753,9 @@ (defun org-icalendar-entry (entry contents info) (org-element-contents inside)) 'timestamp (lambda (ts) - (when (let ((type (org-element-property :type ts))) - (cl-case (plist-get info :with-timestamps) - (active (memq type '(active active-range diary))) - (inactive (memq type '(inactive inactive-range))) - ((t) t))) + (unless (org-export--skip-timestamp-p + (plist-get info :with-timestamps) + (org-element-property :type ts)) (let ((uid (format "TS%d-%s" (cl-incf counter) uid))) (org-icalendar--vevent entry ts uid summary loc desc cat tz class)))) diff --git a/lisp/ox.el b/lisp/ox.el index 6ef0d2699..646d09b51 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -802,10 +802,11 @@ (defcustom org-export-with-timestamps t "Non-nil means allow timestamps in export. It can be set to any of the following values: - t export all timestamps. - `active' export active timestamps only. - `inactive' export inactive timestamps only. - nil do not export timestamps + t export all timestamps. + `active' export active timestamps, including diary timestamps. + `active-exclude-diary' export active timestamps, excluding diary timestamps. + `inactive' export inactive timestamps only. + nil do not export timestamps This only applies to timestamps isolated in a paragraph containing only timestamps. Other timestamps are always @@ -816,10 +817,12 @@ (defcustom org-export-with-timestamps t :group 'org-export-general :type '(choice (const :tag "All timestamps" t) - (const :tag "Only active timestamps" active) + (const :tag "Active timestamps, including diary timestamps" active) + (const :tag "Active timestamps, excluding diary timestamps" + active-exclude-diary) (const :tag "Only inactive timestamps" inactive) (const :tag "No timestamp" nil)) - :safe (lambda (x) (memq x '(t nil active inactive)))) + :safe (lambda (x) (memq x '(t nil active active-exclude-diary inactive)))) (defcustom org-export-with-todo-keywords t "Non-nil means include TODO keywords in export. @@ -1857,13 +1860,23 @@ (defun org-export--skip-p (datum options selected excluded) (lambda (obj) (or (not (stringp obj)) (org-string-nw-p obj))) options t)))) - (cl-case (plist-get options :with-timestamps) - ((nil) t) - (active - (not (memq (org-element-property :type datum) '(active active-range diary)))) - (inactive - (not (memq (org-element-property :type datum) - '(inactive inactive-range))))))))) + (org-export--skip-timestamp-p + (plist-get options :with-timestamps) + (org-element-property :type datum)))))) + +(defun org-export--skip-timestamp-p (with-timestamps timestamp-type) + "Decides whether to skip a timestamp during export. +WITH-TIMESTAMPS should be a valid option for +`org-export-with-timestamps'. TIMESTAMP-TYPE should be the +`:type' property of a timestamp element." + (cl-case with-timestamps + ((nil) t) + (active + (not (memq timestamp-type '(active active-range diary)))) + (active-exclude-diary + (not (memq timestamp-type '(active active-range)))) + (inactive + (not (memq timestamp-type '(inactive inactive-range)))))) ;;; The Transcoder diff --git a/testing/lisp/test-ox-icalendar.el b/testing/lisp/test-ox-icalendar.el index c7c74c526..8c0ab6377 100644 --- a/testing/lisp/test-ox-icalendar.el +++ b/testing/lisp/test-ox-icalendar.el @@ -143,5 +143,20 @@ (ert-deftest test-ox-icalendar/diary-timestamp () (should (search-forward "RRULE:FREQ=MONTHLY;BYDAY=1SU")))) (when (file-exists-p tmp-ics) (delete-file tmp-ics))))) +(ert-deftest test-ox-icalendar/exclude-diary-timestamp () + "Test icalendar exclude of diary timestamps." + (let* ((org-icalendar-with-timestamps 'active-exclude-diary) + (tmp-ics (org-test-with-temp-text-in-file + "* Test entry with 2 timestamps +<%%(diary-float t 0 1)> +<2025-01-12 Sunday>" + (expand-file-name (org-icalendar-export-to-ics))))) + (unwind-protect + (with-temp-buffer + (insert-file-contents tmp-ics) + (save-excursion + (should (not (search-forward "RRULE:FREQ=MONTHLY;BYDAY=1SU" nil t))))) + (when (file-exists-p tmp-ics) (delete-file tmp-ics))))) + (provide 'test-ox-icalendar) ;;; test-ox-icalendar.el ends here -- 2.47.1 --=-=-=--