From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#72831: [PATCH] gnus-icalendar: Allow comments in event replies Date: Wed, 28 Aug 2024 15:45:10 +0200 Message-ID: <87wmk0vk0p.fsf@gmail.com> References: <875xrml22f.fsf@pie.tf> <868qwgj4fh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29773"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Andrew G Cohen , Alexandre Duret-Lutz , 72831@debbugs.gnu.org To: Ferdinand Pieper Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 28 15:47:39 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 1sjJ1O-0007YT-9Y for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Aug 2024 15:47:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjJ10-0003UE-Nx; Wed, 28 Aug 2024 09:47:14 -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 1sjJ0y-0003KJ-54 for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2024 09:47:12 -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 1sjJ0u-0002lV-Pf for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2024 09:47:11 -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=INbcTQlbRATzkOuStvBQUzM4fjjPTmtb4ZPEjtFKzt0=; b=o45kGY0Va22y5IE8zMpt2h0BJwewvmPZczCxBrfLNF4yx8haQarSfAsvqL0MChAs/1afBRmUDp9f6i7kL48VO8cv0+eGZv3hxSA5xGuguNwQ2cyL6GKeJCX1Hw/yqs/HwfI9Q5CG4GGGOnOw6wQTytk/Wagpd46p2vNUIhgO32gGUhmUvyGsnazzxSVLEoW0eg2/r8LcDHQru8DNs57MDmx0rBk4DB39r/3/UvhBsE0LiuiQQUgXhsDZ9p7ZdunH1LecPEJfeFqVkSn9nlwSl0KCgX2ivKs8bTXQp/jOCRuDd0xEO1PGj/vih29FPBkVZmfbAEtX7jRr1zY0tlQo8A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sjJ1m-0004u8-GG for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2024 09:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Aug 2024 13:48:02 +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.172485284018794 (code B ref 72831); Wed, 28 Aug 2024 13:48:02 +0000 Original-Received: (at 72831) by debbugs.gnu.org; 28 Aug 2024 13:47:20 +0000 Original-Received: from localhost ([127.0.0.1]:48496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sjJ15-0004t4-Qr for submit@debbugs.gnu.org; Wed, 28 Aug 2024 09:47:20 -0400 Original-Received: from mail-wr1-f52.google.com ([209.85.221.52]:49250) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sjJ12-0004sl-1K for 72831@debbugs.gnu.org; Wed, 28 Aug 2024 09:47:18 -0400 Original-Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3719753d365so3825134f8f.2 for <72831@debbugs.gnu.org>; Wed, 28 Aug 2024 06:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852714; x=1725457514; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=INbcTQlbRATzkOuStvBQUzM4fjjPTmtb4ZPEjtFKzt0=; b=Hz61D4RMWE5RFJ2AWBviPDUfVlZik3n6gMXl3gxw61D67LUwWE+pK4VfHhTabbuoOQ miJxYA1R8NKrF7CKhF7u/FOmZCy5agUdtkin3GQ3ijnkCLv6J3cEX2EPABY8ZjZwrRSb yFhYsYiYvlzwR8JTl2N5hUma8I/fEck1511MtORbRE+YslrU4rDvs97+ONnmdFCz5RuI iGlWgFCitlRY2GxvcisU4y21gVU5zrLmL62cVUU9n8tiwyVJPN/U9KmR+fDAdj9khS8C 49d+PpGyq6jrzPV1OXohu6mJJZNOcCuDwe3taBEjJUIzrVp/6jwvaVHRr/kMPJePlH2X H0GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852714; x=1725457514; h=content-transfer-encoding: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=INbcTQlbRATzkOuStvBQUzM4fjjPTmtb4ZPEjtFKzt0=; b=goKkqW8RCWB09OFPp2K4XQ7fXMk1cua0hfnIky6OfTtJOc4CHSwSMStYAtEWe6EPgc kIAyPIHh/O3Qk2srb7bukWHMOqJuqPb2FDNukwLg09i5+78S16Ait0/yJFuRIQG3mevN 9KMsMOk/MKEpmvB9XwRcaBGt+q6UUejmZCbJieIX4B61oVOcHkj7t6xp5yiNkb19RQwk 9Gy19/jGL9boP2BkE7RrC07334sZCGwsI/qdBSOshTM26B/tAc8dGy+xcgeg8jq2/aX1 5rDNsovo7SDoyoYXuEfFo4i64liZgmRQbM8sHWWVvg6//d+vB23oP9s5pFQbWdqqzX2H n2Yg== X-Forwarded-Encrypted: i=1; AJvYcCW1WfTpp+3LHOweJySsC+VvG45L2NE5ZmiIXEfrVWa0BpG9/rIKzJwY6F8/lOgkUaYDzB3d8Q==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwvDfTvvi0BZsApI7M32ZqxiNIerwH7hrQDXA8/FPbMjmw3QxmI hqzIfIlDkhDp4cy3J5oljgFz2Y7qGvtQuJNm3rltLL1JuftUC2iPeDxcFw== X-Google-Smtp-Source: AGHT+IHWvRxevE/KLY4wJm6tnPiwhW93lWl1DommB16uAddCVRnbDpiUyCcvQBjxmNQVhthxAQGj2Q== X-Received: by 2002:a5d:400c:0:b0:371:8c79:73c1 with SMTP id ffacd0b85a97d-3731187e96dmr11795547f8f.2.1724852714143; Wed, 28 Aug 2024 06:45:14 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb51:a1f0:1387:9567:d5c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63a679esm21746115e9.14.2024.08.28.06.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:45:12 -0700 (PDT) In-Reply-To: <868qwgj4fh.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 28 Aug 2024 14:02:42 +0300") 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:290866 Archived-At: >>>>> On Wed, 28 Aug 2024 14:02:42 +0300, Eli Zaretskii said: >> From: Ferdinand Pieper >> Date: Tue, 27 Aug 2024 11:58:32 +0200 >>=20 >> Tags: patch >>=20 >> The iCalendar RFC allows comments in an event reply to e.g. indicate >> a reason for declining. This patch implements sending an additional >> comment if the usual functions >> `gnus-icalendar-reply-[accept,decline,tentative]` (bound to `i a`, >> `i d`, `i t`) are called with a prefix argument. >>=20 >> Please let me know any feedback regarding the patch and commit >> message formatting. Now that you have the bug number, please put (Bug#72831) somewhere in the commit message. >>=20 >> Notably this only implements the comment functionality for the >> functions mentioned above and does not include the buttons defined >> in `gnus-icalendar-event:inline-reply-buttons`, as I am not sure how >> the `read-string` for the user's comment should be implemented for >> them. You can pass prefix args to commands bound to mouse clicks as well as keys pressed inside the button, but getting the pieces to work would take some experimentation. I don=CA=BCt think that=CA=BCs necessary for an initial implementation though. Eli> Thanks. Eli> Robert, Andrew, and Alexandre: would you please review the proposed Eli> changes below and comment? I think a change this size requires copyright assigment, which I don=CA=BCt know if you=CA=BCve done. >> >From 8ff07723b407d56de72ddfea98b8931951bb7ad8 Mon Sep 17 00:00:00 2= 001 >> From: fpi >> Date: Mon, 19 Aug 2024 17:18:11 +0200 >> Subject: [PATCH] Allow comments to organizer in ical event replies >>=20 >> * 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. I think that if you=CA=BCre making the same comment for the three functions you can put all three in one set of (), separated by commas. >> --- >> lisp/gnus/gnus-icalendar.el | 52 ++++++++++++++++++++++++++---------= -- >> 1 file changed, 37 insertions(+), 15 deletions(-) >>=20 >> diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.= el >> index af7284b88e8..7a295fb9ed2 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 >> ;;; >>=20 >> -(defun gnus-icalendar-event--build-reply-event-body (ical-request s= tatus identities) >> +(defun gnus-icalendar-event--build-reply-event-body (ical-request s= tatus 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=3D key "ATTENDEE") (update-attendee-status line)) >> ((string=3D key "SUMMARY") (update-summary line)) >> + ((string=3D key "COMMENT") (update-comment line)) >> ((string=3D key "DTSTAMP") (update-dtstamp)) >> ((member key '("ORGANIZER" "DTSTART" "DTEND" >> "LOCATION" "DURATION" "SEQUENCE" >> @@ -363,12 +368,17 @@ gnus-icalendar-event--build-reply-event-body >> attendee-status user-full-name user-mail-address) >> reply-event-lines)) >>=20 >> + ;; add comment line if not existing >> + (when (and comment (not (gnus-icalendar-find-if (lambda (x) (= string-match "^COMMENT" x)) >> + reply-event-l= ines))) >> + (push (format "COMMENT:%s" comment) reply-event-lines)) >> + So if the event was sent with a COMMENT the receiver can=CA=BCt add their own? That doesn=CA=BCt match my conception of 'reply with comment'. I=CA=BCm hazy on what=CA=BCs exactly allowed in ical, can you have more than one COMMENT line? Or we could combine the comments? >> (mapconcat #'identity `("BEGIN:VEVENT" >> ,@(nreverse reply-event-lines) >> "END:VEVENT") >> "\n")))) >>=20 >> -(defun gnus-icalendar-event-reply-from-buffer (buf status identitie= s) >> +(defun gnus-icalendar-event-reply-from-buffer (buf status identitie= s &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 Could you describe the COMMENT arg in the docstring? >> @@ -396,7 +406,7 @@ gnus-icalendar-event-reply-from-buffer >> "PRODID:Gnus" >> "VERSION:2.0" >> zone >> - (gnus-icalendar-event--build-reply-ev= ent-body event status identities) >> + (gnus-icalendar-event--build-reply-ev= ent-body event status identities comment) >> "END:VCALENDAR"))) >>=20 >> (mapconcat #'identity (delq nil contents) "\n")))))) >> @@ -878,13 +888,13 @@ gnus-icalendar-send-buffer-by-mail >> (insert "Subject: " subject) >> (message-send-and-exit)))) >>=20 >> -(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-identiti= es)))) >> + (current-buffer) status (gnus-icalendar-identiti= es) comment))) >> (organizer (gnus-icalendar-event:organizer event))) >>=20 >> (when reply >> @@ -1009,25 +1019,37 @@ gnus-icalendar-save-event >> (when data >> (gnus-icalendar-save-part data)))) >>=20 >> -(defun gnus-icalendar-reply-accept () >> - "Accept invitation in the current article." >> +(defun gnus-icalendar-reply-accept (&optional comment-p) >> + "Accept invitation in the current article. >> + >> +With a prefix `\\[universal-argument]' prompt for a comment to incl= ude >> +in the reply." I think we tend to word this as "Optional argument COMMENT-P (interactively the prefix argument) means prompt for a comment to include in the reply." >> (interactive nil gnus-article-mode gnus-summary-mode) >> (with-current-buffer gnus-article-buffer >> - (gnus-icalendar-reply (list gnus-icalendar-handle 'accepted gnu= s-icalendar-event)) >> + (gnus-icalendar-reply (list gnus-icalendar-handle 'accepted gnu= s-icalendar-event) >> + (when comment-p (read-string "Comment: ")= )) >> (setq-local gnus-icalendar-reply-status 'accepted))) >>=20 >> -(defun gnus-icalendar-reply-tentative () >> - "Send tentative response to invitation in the current article." >> +(defun gnus-icalendar-reply-tentative (&optional comment-p) >> + "Send tentative response to invitation in the current article. >> + >> +With a prefix `\\[universal-argument]' prompt for a comment to incl= ude >> +in the reply." >> (interactive nil gnus-article-mode gnus-summary-mode) >> (with-current-buffer gnus-article-buffer >> - (gnus-icalendar-reply (list gnus-icalendar-handle 'tentative gn= us-icalendar-event)) >> + (gnus-icalendar-reply (list gnus-icalendar-handle 'tentative gn= us-icalendar-event) >> + (when comment-p (read-string "Comment: ")= )) >> (setq-local gnus-icalendar-reply-status 'tentative))) >>=20 >> -(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. >> + >> +With a prefix `\\[universal-argument]' prompt for a comment to incl= ude >> +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 gnu= s-icalendar-event)) >> + (gnus-icalendar-reply (list gnus-icalendar-handle 'declined gnu= s-icalendar-event) >> + (when comment-p (read-string "Comment: ")= )) >> (setq-local gnus-icalendar-reply-status 'declined))) >>=20 >> (defun gnus-icalendar-event-export () >> --=20 >> 2.30.2 >>=20 Ideally you=CA=BCd add test cases for this to "test/lisp/gnus/gnus-icalendar-tests.el". But that=CA=BCs not mandatory. Robert --=20