From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ferdinand Pieper Newsgroups: gmane.emacs.bugs Subject: bug#72831: [PATCH] gnus-icalendar: Allow comments in event replies Date: Sat, 07 Sep 2024 14:22:41 +0200 Message-ID: <87h6ard566.fsf@pie.tf> References: <875xrml22f.fsf@pie.tf> <868qwgj4fh.fsf@gnu.org> <87wmk0vk0p.fsf@gmail.com> <878qwgtxjo.fsf@pie.tf> <87o75bvk8q.fsf@gmail.com> <87zfossr0j.fsf@pie.tf> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35423"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Robert Pluim , Eli Zaretskii , Alexandre Duret-Lutz , Andrew G Cohen To: 72831@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 07 16:44:37 2024 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 1smwg1-00093B-37 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Sep 2024 16:44:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smwfX-000284-8J; Sat, 07 Sep 2024 10:44:07 -0400 Original-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 1smwfU-000277-Uv for bug-gnu-emacs@gnu.org; Sat, 07 Sep 2024 10:44:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smwfU-0003Lh-L2 for bug-gnu-emacs@gnu.org; Sat, 07 Sep 2024 10:44:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=6YGdatoURjyLlGU7a6nXruM8FB00JlqqcKTB5rccI2Y=; b=dXKS49FZ0kKIpZkBRp49eU3m+JUpFtIJTH14We6nNG0z+U0HooqsdXPQdSkSqBDWyQdTuKjtk5RNpyhxgKFCu/7WjYFymPCuYyPFgJFVxaLOdxg5JQJ2jjwUcqPXdDgV8bEnU+phgvzcULr2tNFVdvv5pZ4EhmM6Ctu7ewazqSAf/dL0gzh+l5X3Flf9ymTKYbBbC7JzR+OPQaxQSJf7BckJtltGNehykhJJXekn+C2NIQMn7HLcwIZtei9NQ0/9LQSW71xHeOLHCr6BsyBzDidpU9ozn+kmm6k55DJlvaQtOAD52KuX2D6r7rd8WboVvrMWgQB1hHk16OEatPfF3A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1smwfV-0000V1-Fq for bug-gnu-emacs@gnu.org; Sat, 07 Sep 2024 10:44:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ferdinand Pieper Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Sep 2024 14:44:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72831 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 72831-submit@debbugs.gnu.org id=B72831.17257202181799 (code B ref 72831); Sat, 07 Sep 2024 14:44:05 +0000 Original-Received: (at 72831) by debbugs.gnu.org; 7 Sep 2024 14:43:38 +0000 Original-Received: from localhost ([127.0.0.1]:57167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smwf3-0000So-3X for submit@debbugs.gnu.org; Sat, 07 Sep 2024 10:43:38 -0400 Original-Received: from pie.tf ([5.45.99.52]:39638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smuSj-0000Jw-IH for 72831@debbugs.gnu.org; Sat, 07 Sep 2024 08:22:46 -0400 Original-Received: from [45.12.203.65] (helo=localhost) by pie.tf with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1smuSf-000Mh2-Lo; Sat, 07 Sep 2024 12:22:41 +0000 In-Reply-To: <87zfossr0j.fsf@pie.tf> (Ferdinand Pieper's message of "Sat, 31 Aug 2024 16:31:24 +0200") X-Mailman-Approved-At: Sat, 07 Sep 2024 10:43:33 -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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291390 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Any further feedback on the patch or could someone please apply the patch? = Thanks! Patch once again below, this time as attachment instead of inline=E2=80=A6 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-comments-to-organizer-in-event-replies-bug-728.patch >From 5f75ab29fd0f0fbed5238ffff63c6ce13ce1f8de Mon Sep 17 00:00:00 2001 From: fpi Date: Wed, 28 Aug 2024 18:33:20 +0200 Subject: [PATCH] Allow comments to organizer in event replies (bug#72831) * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event--build-reply-event-body): Add optional COMMENT argument to be inserted into the reply. (gnus-icalendar-event-reply-from-buffer): Add COMMENT argument to be passed through to gnus-icalendar-event--build-reply-event-body (gnus-icalendar-reply-accept, gnus-icalendar-reply-tentative, gnus-icalendar-reply-decline): If interactively called with a prefix argument ask user for a COMMENT to add to the reply. * test/lisp/gnus/gnus-icalendar-tests.el (gnus-icalendar-accept-with-comment, gnus-icalendar-decline-withouth-changing-comment): New tests. --- lisp/gnus/gnus-icalendar.el | 61 +++++++++++++++------- test/lisp/gnus/gnus-icalendar-tests.el | 72 ++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 18 deletions(-) diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el index af7284b88e8..85f1aa09a56 100644 --- a/lisp/gnus/gnus-icalendar.el +++ b/lisp/gnus/gnus-icalendar.el @@ -309,7 +309,7 @@ gnus-icalendar-event-from-buffer ;;; gnus-icalendar-event-reply ;;; -(defun gnus-icalendar-event--build-reply-event-body (ical-request status identities) +(defun gnus-icalendar-event--build-reply-event-body (ical-request status identities &optional comment) (let ((summary-status (capitalize (symbol-name status))) (attendee-status (upcase (symbol-name status))) reply-event-lines) @@ -319,6 +319,10 @@ gnus-icalendar-event--build-reply-event-body (if (string-match "^[^:]+:" line) (replace-match (format "\\&%s: " summary-status) t nil line) line)) + (update-comment + (line) + (if comment (format "COMMENT:%s" comment) + line)) (update-dtstamp () (format-time-string "DTSTAMP:%Y%m%dT%H%M%SZ" nil t)) (attendee-matches-identity @@ -341,6 +345,7 @@ gnus-icalendar-event--build-reply-event-body (cond ((string= key "ATTENDEE") (update-attendee-status line)) ((string= key "SUMMARY") (update-summary line)) + ((string= key "COMMENT") (update-comment line)) ((string= key "DTSTAMP") (update-dtstamp)) ((member key '("ORGANIZER" "DTSTART" "DTEND" "LOCATION" "DURATION" "SEQUENCE" @@ -363,16 +368,24 @@ gnus-icalendar-event--build-reply-event-body attendee-status user-full-name user-mail-address) reply-event-lines)) + ;; add comment line if not existing + (when (and comment (not (gnus-icalendar-find-if (lambda (x) (string-match "^COMMENT" x)) + reply-event-lines))) + (push (format "COMMENT:%s" comment) reply-event-lines)) + (mapconcat #'identity `("BEGIN:VEVENT" ,@(nreverse reply-event-lines) "END:VEVENT") "\n")))) -(defun gnus-icalendar-event-reply-from-buffer (buf status identities) +(defun gnus-icalendar-event-reply-from-buffer (buf status identities &optional comment) "Build a calendar event reply for request contained in BUF. The reply will have STATUS (`accepted', `tentative' or `declined'). The reply will be composed for attendees matching any entry -on the IDENTITIES list." +on the IDENTITIES list. +Optional argument COMMENT will be placed in the comment field of the +reply. +" (cl-labels ((extract-block (blockname) @@ -396,7 +409,7 @@ gnus-icalendar-event-reply-from-buffer "PRODID:Gnus" "VERSION:2.0" zone - (gnus-icalendar-event--build-reply-event-body event status identities) + (gnus-icalendar-event--build-reply-event-body event status identities comment) "END:VCALENDAR"))) (mapconcat #'identity (delq nil contents) "\n")))))) @@ -878,13 +891,13 @@ gnus-icalendar-send-buffer-by-mail (insert "Subject: " subject) (message-send-and-exit)))) -(defun gnus-icalendar-reply (data) +(defun gnus-icalendar-reply (data &optional comment) (let* ((handle (car data)) (status (cadr data)) (event (caddr data)) (reply (gnus-icalendar-with-decoded-handle handle (gnus-icalendar-event-reply-from-buffer - (current-buffer) status (gnus-icalendar-identities)))) + (current-buffer) status (gnus-icalendar-identities) comment))) (organizer (gnus-icalendar-event:organizer event))) (when reply @@ -1009,25 +1022,37 @@ gnus-icalendar-save-event (when data (gnus-icalendar-save-part data)))) -(defun gnus-icalendar-reply-accept () - "Accept invitation in the current article." - (interactive nil gnus-article-mode gnus-summary-mode) +(defun gnus-icalendar-reply-accept (&optional comment-p) + "Accept invitation in the current article. + +Optional argument COMMENT-P (interactively the `\\[universal-argument]') +means prompt for a comment to include in the reply." + (interactive "P" gnus-article-mode gnus-summary-mode) (with-current-buffer gnus-article-buffer - (gnus-icalendar-reply (list gnus-icalendar-handle 'accepted gnus-icalendar-event)) + (gnus-icalendar-reply (list gnus-icalendar-handle 'accepted gnus-icalendar-event) + (when comment-p (read-string "Comment: "))) (setq-local gnus-icalendar-reply-status 'accepted))) -(defun gnus-icalendar-reply-tentative () - "Send tentative response to invitation in the current article." - (interactive nil gnus-article-mode gnus-summary-mode) +(defun gnus-icalendar-reply-tentative (&optional comment-p) + "Send tentative response to invitation in the current article. + +Optional argument COMMENT-P (interactively the `\\[universal-argument]') +means prompt for a comment to include in the reply." + (interactive "P" gnus-article-mode gnus-summary-mode) (with-current-buffer gnus-article-buffer - (gnus-icalendar-reply (list gnus-icalendar-handle 'tentative gnus-icalendar-event)) + (gnus-icalendar-reply (list gnus-icalendar-handle 'tentative gnus-icalendar-event) + (when comment-p (read-string "Comment: "))) (setq-local gnus-icalendar-reply-status 'tentative))) -(defun gnus-icalendar-reply-decline () - "Decline invitation in the current article." - (interactive nil gnus-article-mode gnus-summary-mode) +(defun gnus-icalendar-reply-decline (&optional comment-p) + "Decline invitation in the current article. + +Optional argument COMMENT-P (interactively the `\\[universal-argument]') +means prompt for a comment to include in the reply." + (interactive "P" gnus-article-mode gnus-summary-mode) (with-current-buffer gnus-article-buffer - (gnus-icalendar-reply (list gnus-icalendar-handle 'declined gnus-icalendar-event)) + (gnus-icalendar-reply (list gnus-icalendar-handle 'declined gnus-icalendar-event) + (when comment-p (read-string "Comment: "))) (setq-local gnus-icalendar-reply-status 'declined))) (defun gnus-icalendar-event-export () diff --git a/test/lisp/gnus/gnus-icalendar-tests.el b/test/lisp/gnus/gnus-icalendar-tests.el index 08c85013d17..9b4ba383d5a 100644 --- a/test/lisp/gnus/gnus-icalendar-tests.el +++ b/test/lisp/gnus/gnus-icalendar-tests.el @@ -255,5 +255,77 @@ gnus-icalendary-weekly-byday <2020-09-21 14:00-14:30 +1w>"))) (setenv "TZ" tz)))) +(ert-deftest gnus-icalendar-accept-with-comment () + "" + (let ((event "BEGIN:VEVENT +DTSTART;TZID=Europe/Berlin:20200915T140000 +DTEND;TZID=Europe/Berlin:20200915T143000 +RRULE:FREQ=WEEKLY;BYDAY=FR,MO,TH,TU,WE +DTSTAMP:20200915T120627Z +ORGANIZER;CN=anon@anoncompany.com:mailto:anon@anoncompany.com +UID:7b6g3m7iftuo90ei4ul00feqn_R20200915T120000@google.com +ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE + ;CN=participant@anoncompany.com;X-NUM-GUESTS=0:mailto:participant@anoncompany.com +CREATED:20200325T095723Z +DESCRIPTION:Coffee talk +LAST-MODIFIED:20200915T120623Z +LOCATION: +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:Casual coffee talk +TRANSP:OPAQUE +END:VEVENT") + (icalendar-identities '("participant@anoncompany.com"))) + (unwind-protect + (progn + (let* ((reply (with-temp-buffer + (insert event) + (gnus-icalendar-event-reply-from-buffer + (current-buffer) + 'accepted + icalendar-identities + "Can not stay long.")))) + (should (string-match "^ATTENDEE;.*?\\(PARTSTAT=[^;]+\\)" reply)) + (should (string-equal (match-string 1 reply) "PARTSTAT=ACCEPTED")) + (should (string-match "^COMMENT:\\(.*\\)$" reply)) + (should (string-equal (match-string 1 reply) "Can not stay long."))))))) + +(ert-deftest gnus-icalendar-decline-withouth-changing-comment () + "" + (let ((event "BEGIN:VEVENT +DTSTART;TZID=Europe/Berlin:20200915T140000 +DTEND;TZID=Europe/Berlin:20200915T143000 +RRULE:FREQ=WEEKLY;BYDAY=FR,MO,TH,TU,WE +DTSTAMP:20200915T120627Z +ORGANIZER;CN=anon@anoncompany.com:mailto:anon@anoncompany.com +UID:7b6g3m7iftuo90ei4ul00feqn_R20200915T120000@google.com +ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE + ;CN=participant@anoncompany.com;X-NUM-GUESTS=0:mailto:participant@anoncompany.com +CREATED:20200325T095723Z +DESCRIPTION:Coffee talk +LAST-MODIFIED:20200915T120623Z +COMMENT:Only available at 2pm +LOCATION: +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:Casual coffee talk +TRANSP:OPAQUE +END:VEVENT") + (icalendar-identities '("participant@anoncompany.com"))) + (unwind-protect + (progn + (let* ((reply (with-temp-buffer + (insert event) + (gnus-icalendar-event-reply-from-buffer + (current-buffer) + 'declined + icalendar-identities + nil)))) + (should (string-match "^ATTENDEE;.*?\\(PARTSTAT=[^;]+\\)" reply)) + (should (string-equal (match-string 1 reply) "PARTSTAT=DECLINED")) + (should (string-match "^COMMENT:\\(.*\\)$" reply)) + (should (string-equal (match-string 1 reply) "Only available at 2pm")) + ))))) + (provide 'gnus-icalendar-tests) ;;; gnus-icalendar-tests.el ends here -- 2.44.1 --=-=-= Content-Type: text/plain Ferdinand Pieper writes: > The updated patch contains two tests to check replies with and without > a comment. Let me know any feedback on these as I have never > contributed tests so far and if you prefer to have code and tests > split into two commits instead. > > Otherwise the patch should be good to be applied? > > Thanks! --=-=-=--