* bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty
@ 2023-06-12 15:48 Reindert-Jan Ekker
2023-06-12 16:21 ` Robert Pluim
0 siblings, 1 reply; 6+ messages in thread
From: Reindert-Jan Ekker @ 2023-06-12 15:48 UTC (permalink / raw)
To: 64023
I use mu4e for my email and org-mode for managing my calendar.
When I accept a calendar invitation that has *no description* using
gnus-icalendar, and later I receive an update for that invitation, the
code that updates the corresponding org element will remove the
timestamp completely.
This is quite common for invitations from e.g. thunderbird, that have
only a summary but where the description field has been left empty.
To show this in action we would need a complete mu4e and gnus-icalendar
setup, but we can recreate the effect as follows:
we have an org file in "~/test.org" containing an event exported from an
icalendar invitation:
----- contents of test.org -----
* Test
:PROPERTIES:
:ICAL_EVENT: t
:ID: xxx-11-yyy
:ORGANIZER: Me
:LOCATION:
:PARTICIPATION_TYPE: non-participant
:REQ_PARTICIPANTS:
:OPT_PARTICIPANTS:
:RRULE:
:REPLY: Not replied yet
:END:
<2023-08-01 01:00-01:00>
----- end of test.org -----
We can now call the function to update this event to a new date as
follows (this works with emacs -Q):
(require 'gnus-icalendar)
(let ((ev (gnus-icalendar-event :organizer "Me" :summary "Test"
:start-time (encode-time '(0 0 0 1 9 2023 nil nil nil))
:end-time (encode-time '(0 0 0 1 9 2023 nil nil nil))
:uid "xxx-11-yyy"
:recur nil
:description nil)))
(gnus-icalendar--update-org-event ev nil (list (expand-file-name "~/test.org"))))
This results in the following:
----- new contents of test.org -----
* [#C] Test ()
:PROPERTIES:
:ICAL_EVENT: t
:ID: xxx-11-yyy
:ORGANIZER: Me
:PARTICIPATION_TYPE: non-participant
:REPLY: Not replied yet
:END:
----- end of test.org -----
Note how the timestamp has not been updated but completely erased.
This is because in gnus-icalendar--update-org-event, the code for
updating the timestamp is inside "(when description ...)", causing it to
only be run when the description is not empty.
-----
In GNU Emacs 29.0.91 (build 1, aarch64-apple-darwin21.6.0, NS
appkit-2113.60 Version 12.6.5 (Build 21G531)) of 2023-05-31 built on
CodeSensei-Mac-mini.local
Windowing system distributor 'Apple', version 10.3.2299
System Description: macOS 13.4
Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
--infodir=/opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/info/emacs
--prefix=/opt/homebrew/Cellar/emacs-plus@29/29.0.90 --with-xml2
--with-gnutls --without-compress-install --without-dbus
--without-imagemagick --with-modules --with-rsvg --with-ns
--disable-ns-self-contained 'CFLAGS=-Os -w -pipe
-mmacosx-version-min=12
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT'
'CPPFLAGS=-I/opt/homebrew/opt/icu4c/include
-I/opt/homebrew/opt/openssl@1.1/include -isystem/opt/homebrew/include
-F/opt/homebrew/Frameworks
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
'LDFLAGS=-L/opt/homebrew/opt/icu4c/lib
-L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/lib
-F/opt/homebrew/Frameworks -Wl,-headerpad_max_install_names
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk''
Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP XIM ZLIB
Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LC_CTYPE: UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: elisp
Minor modes in effect:
windmove-mode: t
csv-field-index-mode: t
global-diff-hl-mode: t
diff-hl-mode: t
global-anzu-mode: t
anzu-mode: t
volatile-highlights-mode: t
simple-modeline-mode: t
winner-mode: t
burly-tabs-mode: t
rainbow-delimiters-mode: t
global-flycheck-mode: t
flycheck-mode: t
global-company-mode: t
company-mode: t
marginalia-mode: t
vertico-buffer-mode: t
vertico-mode: t
dimmer-mode: t
global-hl-line-mode: t
show-smartparens-global-mode: t
show-smartparens-mode: t
smartparens-strict-mode: t
smartparens-mode: t
global-undo-tree-mode: t
undo-tree-mode: t
super-save-mode: t
recentf-mode: t
savehist-mode: t
save-place-mode: t
override-global-mode: t
magit-wip-initial-backup-mode: t
magit-wip-before-change-mode: t
magit-wip-after-apply-mode: t
magit-wip-after-save-mode: t
magit-wip-mode: t
global-git-commit-mode: t
magit-auto-revert-mode: t
shell-dirtrack-mode: t
server-mode: t
global-auto-revert-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
/Users/reindert/.emacs.d/elpa/transient-20221127.2242/transient hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/transient
~/.emacs.d/rje/custom hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/custom
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-jump hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-jump
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-diminish hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-diminish
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-delight hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-delight
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-lint hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-lint
/Users/reindert/.emacs.d/elpa/bind-key-20221117.1610/bind-key hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/bind-key
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-core hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-core
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-ensure hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-ensure
/Users/reindert/.emacs.d/elpa/use-package-20221127.2217/use-package-bind-key hides /opt/homebrew/Cellar/emacs-plus@29/29.0.90/share/emacs/29.0.91/lisp/use-package/use-package-bind-key
Features:
(shadow so-long view emacsbug windmove cl-print debug backtrace pulse
consult-xref help-fns radix-tree hippie-exp ace-window avy csv-mode sort
oc-basic bibtex ol-w3m org-inlinetask ol-info ol-eww eww url-queue
mm-url ol-doi org-link-doi ol-docview doc-view jka-compr image-mode exif
org-ctags dired-aux vc-hg vc-git vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs diff-hl-dired embark-consult consult-vertico consult compat-28
vertico-directory cursor-sensor warnings rje-ical-export rje-looks
diff-hl log-view vc-dir ewoc vc vc-dispatcher anzu etags fileloop xref
volatile-highlights whitespace simple-modeline simple-modeline-segments
simple-modeline-core rje-windows winner rje-keys rje-tab-bar burly-tabs
burly frameset move-text rje-dired dired-x rje-programming
rainbow-delimiters flycheck embark ffap hl-todo rje-project eshell
esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups
esh-util rje-vterm rje-company company-oddmuse company-keywords
company-dabbrev-code company-dabbrev company-files company-capf
company-cmake company rje-pass password-store auth-source-pass
rje-agenda mu4e-icalendar gnus-icalendar icalendar diary-lib
diary-loaddefs org-capture rje-vertico-embark marginalia orderless
vertico-buffer vertico rje-theme dimmer color rje-mail mixed-pitch
face-remap cus-edit mu4e mu4e-org mu4e-notification mu4e-main mu4e-view
gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum
gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail
mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win gnus
nnheader range mu4e-headers mu4e-compose mu4e-draft mu4e-actions
smtpmail mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message
shr pixel-fill kinsoku url-file svg dom flow-fill hl-line mu4e-contacts
mu4e-update mu4e-folders mu4e-context mu4e-query-items mu4e-server
mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window ido
mu4e-obsolete f f-shortdoc shortdoc rje-edit zop-to-char sudo-edit
smartparens-config smartparens-org smartparens-text smartparens-python
smartparens advice thingatpt rje-org-sync rje-notify s notifications
dbus xml rje-org imenu-list hideshow ox-odt rng-loc rng-uri rng-parse
rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok
nxml-util ox-latex ox-icalendar org-agenda ox-html table ox-ascii
ox-publish ox org-element org-persist xdg avl-tree generator yasnippet
org-journal org-crypt cal-iso org-tempo tempo rje-savefiles tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat
parse-time iso8601 ls-lisp nsm undo-tree queue super-save recentf
tree-widget wid-edit bookmark pp savehist org-id org-refile org
org-macro org-pcomplete org-list org-footnote org-faces org-entities
noutline outline icons ob-clojure ob-emacs-lisp ob-plantuml ob-ditaa
ob-python python project pcase treesit ob-shell ob ob-tangle org-src
ob-ref ob-lob ob-table ob-exp ob-comint ob-core ob-eval org-cycle
org-table ol org-fold org-fold-core org-keys oc org-loaddefs find-func
cal-menu calendar cal-loaddefs org-compat org-version org-macs saveplace
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key use-package-core rje-packages finder-inf
epl rje-vars magit-wip magit-log which-func imenu magit-diff smerge-mode
diff diff-mode easy-mmode git-commit log-edit message sendmail
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor shell pcomplete comint
ansi-osc ring server ansi-color magit-mode transient cl-extra edmacro
kmacro help-mode magit-git magit-base magit-section format-spec crm dash
compat-27 compat-26 compat compat-macs autorevert filenotify delsel
cus-load pyvenv-auto-autoloads pyvenv-autoloads org-ai-autoloads rx info
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)
Memory information:
((conses 16 530456 111783)
(symbols 48 43929 20)
(strings 32 161589 6958)
(string-bytes 1 5371169)
(vectors 16 91381)
(vector-slots 8 1399605 44059)
(floats 8 673 442)
(intervals 56 11004 1871)
(buffers 984 26))
--
Reindert-Jan Ekker
Code Sensei
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty
2023-06-12 15:48 bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty Reindert-Jan Ekker
@ 2023-06-12 16:21 ` Robert Pluim
[not found] ` <m25y7sa6j0.fsf@codesensei.nl>
0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2023-06-12 16:21 UTC (permalink / raw)
To: Reindert-Jan Ekker; +Cc: 64023
>>>>> On Mon, 12 Jun 2023 17:48:27 +0200, Reindert-Jan Ekker <info@codesensei.nl> said:
Reindert-Jan> This is because in gnus-icalendar--update-org-event, the code for
Reindert-Jan> updating the timestamp is inside "(when description ...)", causing it to
Reindert-Jan> only be run when the description is not empty.
I was sure Iʼd fixed this already, but that was in `gnus-icalendar-event->org-entry', not
`gnus-icalendar--update-org-event'
How does this work for you:
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index 0d776cd1bca..542e2a621a0 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -642,16 +642,16 @@ gnus-icalendar--update-org-event
(delete-region (point) entry-end))
;; put new event description in the entry body
- (when description
- (save-restriction
- (narrow-to-region (point) (point))
- (insert "\n"
- (gnus-icalendar-event:org-timestamp event)
- "\n\n"
- (replace-regexp-in-string "[\n]+$" "\n" description)
- "\n")
- (indent-region (point-min) (point-max) (1+ entry-outline-level))
- (fill-region (point-min) (point-max))))
+ (save-restriction
+ (narrow-to-region (point) (point))
+ (insert "\n"
+ (gnus-icalendar-event:org-timestamp event)
+ "\n\n"
+ (replace-regexp-in-string "[\n]+$" "\n"
+ (or description "No description"))
+ "\n")
+ (indent-region (point-min) (point-max) (1+ entry-outline-level))
+ (fill-region (point-min) (point-max)))
;; update entry properties
(cl-labels
Robert
--
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty
[not found] ` <m25y7sa6j0.fsf@codesensei.nl>
@ 2023-06-13 10:48 ` Robert Pluim
2023-06-13 11:24 ` Eli Zaretskii
2023-06-16 18:45 ` Reindert-Jan Ekker
0 siblings, 2 replies; 6+ messages in thread
From: Robert Pluim @ 2023-06-13 10:48 UTC (permalink / raw)
To: Reindert-Jan Ekker; +Cc: 64023
(please keep the bug address in CC)
>>>>> On Mon, 12 Jun 2023 20:16:30 +0200, Reindert-Jan Ekker <info@codesensei.nl> said:
Reindert-Jan> Yes, that works!
OK. Eli, emacs-29 or master? Itʼs a pretty small change, but itʼs not
a regression as such.
Reindert-Jan> By the way, what is the intended behaviour of
Reindert-Jan> gnus-icalendar--cancel-org-event? It seems to search for a property "DT"
Reindert-Jan> that does not exist (at least in my files), so it does not change the
Reindert-Jan> event. Is this a bug or am I missing some configuration somewhere?
It looks like a bug. I canʼt find any code creating such a property,
the current code inserts the timestamp in the body of the org entry.
Robert
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty
2023-06-13 10:48 ` Robert Pluim
@ 2023-06-13 11:24 ` Eli Zaretskii
2023-06-13 12:45 ` Robert Pluim
2023-06-16 18:45 ` Reindert-Jan Ekker
1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2023-06-13 11:24 UTC (permalink / raw)
To: Robert Pluim; +Cc: 64023, info
> Cc: 64023@debbugs.gnu.org
> From: Robert Pluim <rpluim@gmail.com>
> Date: Tue, 13 Jun 2023 12:48:20 +0200
>
> >>>>> On Mon, 12 Jun 2023 20:16:30 +0200, Reindert-Jan Ekker <info@codesensei.nl> said:
>
> Reindert-Jan> Yes, that works!
>
> OK. Eli, emacs-29 or master? Itʼs a pretty small change, but itʼs not
> a regression as such.
Master, please.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty
2023-06-13 11:24 ` Eli Zaretskii
@ 2023-06-13 12:45 ` Robert Pluim
0 siblings, 0 replies; 6+ messages in thread
From: Robert Pluim @ 2023-06-13 12:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 64023, info
tags 64023 fixed
close 64023 30.1
quit
>>>>> On Tue, 13 Jun 2023 14:24:01 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> Cc: 64023@debbugs.gnu.org
>> From: Robert Pluim <rpluim@gmail.com>
>> Date: Tue, 13 Jun 2023 12:48:20 +0200
>>
>> >>>>> On Mon, 12 Jun 2023 20:16:30 +0200, Reindert-Jan Ekker <info@codesensei.nl> said:
>>
Reindert-Jan> Yes, that works!
>>
>> OK. Eli, emacs-29 or master? Itʼs a pretty small change, but itʼs not
>> a regression as such.
Eli> Master, please.
Closing.
Committed as daf7902ed9d
Robert
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty
2023-06-13 10:48 ` Robert Pluim
2023-06-13 11:24 ` Eli Zaretskii
@ 2023-06-16 18:45 ` Reindert-Jan Ekker
1 sibling, 0 replies; 6+ messages in thread
From: Reindert-Jan Ekker @ 2023-06-16 18:45 UTC (permalink / raw)
To: Robert Pluim; +Cc: 64023
[-- Attachment #1: Type: text/plain, Size: 182 bytes --]
As a little exercise I've been writing some unit tests for the bug you
fixed regarding updates to events with empty description. Patch is
attached. Looking forward to any feedback.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch: unit tests --]
[-- Type: text/x-patch, Size: 7608 bytes --]
From 67859adc32616c2251f507b89010968cc9246034 Mon Sep 17 00:00:00 2001
From: reindert <info@codesensei.nl>
Date: Fri, 16 Jun 2023 20:39:00 +0200
Subject: [PATCH] ; * test/lisp/gnus/gnus-icalendar-tests.el: Add tests for
Bug#64023
---
test/lisp/gnus/gnus-icalendar-tests.el | 167 +++++++++++++++++++++++++
1 file changed, 167 insertions(+)
diff --git a/test/lisp/gnus/gnus-icalendar-tests.el b/test/lisp/gnus/gnus-icalendar-tests.el
index 8f89e8f..aab9a88 100644
--- a/test/lisp/gnus/gnus-icalendar-tests.el
+++ b/test/lisp/gnus/gnus-icalendar-tests.el
@@ -27,6 +27,7 @@
;;; Code:
(require 'ert)
+(require 'ert-x)
(require 'gnus-icalendar)
@@ -255,5 +256,171 @@ gnus-icalendary-weekly-byday
<2020-09-21 14:00-14:30 +1w>")))
(setenv "TZ" tz))))
+
+(ert-deftest gnus-icalendar-org-entry-from-ics ()
+ "Test creation of org mode entry from ics string."
+ ;; Use this form so as not to rely on system tz database.
+ ;; Eg hydra.nixos.org.
+ (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+ (let ((event (gnus-icalendar-tests--get-ical-event "BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:5e61e65c-c991-4e42-bd41-44fcf057ea11
+SUMMARY:test appointment
+ORGANIZER;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:info@example.com
+ATTENDEE;CN=Me;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:me@example.com
+ATTENDEE;CN=Myself;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:myself@example.com
+DTSTART;TZID=Europe/Brussels:20230811T160000
+DTEND;TZID=Europe/Brussels:20230811T170000
+DESCRIPTION;ALTREP=\"data:text/html,%3Cbody%3ELet's%20code%3C%2Fbody%3E\":Let's code
+LOCATION:At home
+END:VEVENT
+END:VCALENDAR")))
+ (should (string= (substring-no-properties (gnus-icalendar-event->org-entry event nil))
+ "* test appointment (At home)
+:PROPERTIES:
+:ICAL_EVENT: t
+:ID: 5e61e65c-c991-4e42-bd41-44fcf057ea11
+:ORGANIZER: info@example.com
+:LOCATION: At home
+:PARTICIPATION_TYPE: non-participant
+:REQ_PARTICIPANTS: Me, Myself
+:OPT_PARTICIPANTS:
+:RRULE:
+:REPLY: Not replied yet
+:END:
+
+ <2023-08-11 16:00-17:00>
+
+ Let's code"))))
+
+
+(ert-deftest gnus-icalendar-org-entry-from-ics-no-loc-no-desc ()
+ "Test creation of org mode entry from ics string, no location, no description."
+ ;; Use this form so as not to rely on system tz database.
+ ;; Eg hydra.nixos.org.
+ (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+ (let ((event (gnus-icalendar-tests--get-ical-event "BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:5e61e65c-c991-4e42-bd41-44fcf057ea11
+SUMMARY:test appointment
+ORGANIZER;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:info@example.com
+ATTENDEE;CN=Me;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:me@example.com
+ATTENDEE;CN=Myself;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:myself@example.com
+DTSTART;TZID=Europe/Brussels:20230811T160000
+DTEND;TZID=Europe/Brussels:20230811T170000
+END:VEVENT
+END:VCALENDAR")))
+ (should (string= (substring-no-properties (gnus-icalendar-event->org-entry event nil))
+ "* test appointment
+:PROPERTIES:
+:ICAL_EVENT: t
+:ID: 5e61e65c-c991-4e42-bd41-44fcf057ea11
+:ORGANIZER: info@example.com
+:LOCATION:
+:PARTICIPATION_TYPE: non-participant
+:REQ_PARTICIPANTS: Me, Myself
+:OPT_PARTICIPANTS:
+:RRULE:
+:REPLY: Not replied yet
+:END:
+
+ <2023-08-11 16:00-17:00>
+
+ No description"))))
+
+
+(defconst gnus-icalendar-tests--org-entry-no-desc
+ "* Org entry with empty description
+:PROPERTIES:
+:ICAL_EVENT: t
+:ID: xxx-11-yyy
+:ORGANIZER: No idea
+:LOCATION: Nowhere
+:PARTICIPATION_TYPE: non-participant
+:REQ_PARTICIPANTS:
+:OPT_PARTICIPANTS:
+:RRULE:
+:REPLY: Not replied yet
+:END:
+
+ <2023-01-01 13:00-14:00>")
+
+
+(defun gnus-icalender-tests--get-updated-event (description)
+ "Create updated event with DESCRIPTION and new date 2024-01-01.
+
+If DESCRIPTION is nil, we don't add a description line at all."
+ ;; Use this form so as not to rely on system tz database.
+ ;; Eg hydra.nixos.org.
+ (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+ (let ((description (if description (format "DESCRIPTION:%s\n" description) "")))
+ (gnus-icalendar-tests--get-ical-event (format "BEGIN:VCALENDAR
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:xxx-11-yyy
+SUMMARY:Updated event
+ORGANIZER;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:info@example.com
+DTSTART;TZID=Europe/Brussels:20240101T180000
+DTEND;TZID=Europe/Brussels:20240101T190000
+%s
+LOCATION:unknown
+END:VEVENT
+END:VCALENDAR" description))))
+
+
+(ert-deftest gnus-icalendar-update-org-event-no-description-add ()
+ "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64023 .
+
+Update an existing org event that has no description; add description.
+Check timestamp has changed."
+ (ert-with-temp-file
+ calendar-file :suffix ".org" :text gnus-icalendar-tests--org-entry-no-desc
+ (gnus-icalendar--update-org-event (gnus-icalender-tests--get-updated-event "New description")
+ 'accepted `(,calendar-file))
+ (with-current-buffer (find-buffer-visiting calendar-file)
+ (let ((new-entry (buffer-substring-no-properties (point-min) (point-max))))
+ (should (string-match-p (regexp-quote "<2024-01-01 18:00-19:00>") new-entry))
+ (should (string-match-p (regexp-quote "New description") new-entry))
+ (should-not (string-match-p (regexp-quote "<2023-01-01 13:00-14:00>") new-entry))
+ (should-not (string-match-p (regexp-quote "No description") new-entry))))))
+
+
+(ert-deftest gnus-icalendar-update-org-event-keep-no-description ()
+ "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64023 .
+
+Update an existing org event that has no description; keep it empty.
+Check timestamp has changed."
+ (ert-with-temp-file
+ calendar-file :suffix ".org" :text gnus-icalendar-tests--org-entry-no-desc
+ (let ((event (gnus-icalender-tests--get-updated-event nil)))
+ (gnus-icalendar--update-org-event event 'accepted `(,calendar-file))
+ (with-current-buffer (find-buffer-visiting calendar-file)
+ (let ((new-entry (buffer-substring-no-properties (point-min) (point-max))))
+ (should (string-match-p (regexp-quote "<2024-01-01 18:00-19:00>") new-entry))
+ (should (string-match-p (regexp-quote "No description") new-entry))
+ (should-not (string-match-p (regexp-quote "<2023-01-01 13:00-14:00>") new-entry)))))))
+
+
+(ert-deftest gnus-icalendar-update-org-event-remove-description ()
+ "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64023 .
+
+Update an existing org event that has a description; set description empty."
+ (ert-with-temp-file
+ calendar-file :suffix ".org" :text gnus-icalendar-tests--org-entry-no-desc
+ (let ((event (gnus-icalender-tests--get-updated-event nil)))
+ (oset event :description nil)
+ (gnus-icalendar--update-org-event event'accepted `(,calendar-file))
+ (with-current-buffer (find-buffer-visiting calendar-file)
+ (let ((new-entry (buffer-substring-no-properties (point-min) (point-max))))
+ (should (string-match-p (regexp-quote "<2024-01-01 18:00-19:00>") new-entry))
+ (should (string-match-p (regexp-quote "No description") new-entry))
+ (should-not (string-match-p (regexp-quote "<2023-01-01 13:00-14:00>") new-entry)))))))
+
(provide 'gnus-icalendar-tests)
;;; gnus-icalendar-tests.el ends here
--
2.40.1
[-- Attachment #3: Type: text/plain, Size: 867 bytes --]
Robert Pluim <rpluim@gmail.com> writes:
> (please keep the bug address in CC)
>
>>>>>> On Mon, 12 Jun 2023 20:16:30 +0200, Reindert-Jan Ekker <info@codesensei.nl> said:
>
> Reindert-Jan> Yes, that works!
>
> OK. Eli, emacs-29 or master? Itʼs a pretty small change, but itʼs not
> a regression as such.
>
> Reindert-Jan> By the way, what is the intended behaviour of
> Reindert-Jan> gnus-icalendar--cancel-org-event? It seems to search for a property "DT"
> Reindert-Jan> that does not exist (at least in my files), so it does not change the
> Reindert-Jan> event. Is this a bug or am I missing some configuration somewhere?
>
> It looks like a bug. I canʼt find any code creating such a property,
> the current code inserts the timestamp in the body of the org entry.
>
> Robert
--
Reindert-Jan Ekker
Code Sensei
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-16 18:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12 15:48 bug#64023: 29.0.91; gnus-icalendar does not update timestamp when description is empty Reindert-Jan Ekker
2023-06-12 16:21 ` Robert Pluim
[not found] ` <m25y7sa6j0.fsf@codesensei.nl>
2023-06-13 10:48 ` Robert Pluim
2023-06-13 11:24 ` Eli Zaretskii
2023-06-13 12:45 ` Robert Pluim
2023-06-16 18:45 ` Reindert-Jan Ekker
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).