about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJake Coble2025-06-15 20:01:26 -0400
committerArun Isaac2025-06-18 02:38:36 +0100
commitee9242a9b5ee69821c1dd8de258ecfd6ad616802 (patch)
tree159482c0f73d00ec874898a62f311176adf27478
parentf5f7bd5e2c276a2c3a22039d9cd4f24427a5fd13 (diff)
downloadvaruga-ee9242a9b5ee69821c1dd8de258ecfd6ad616802.tar.gz
varuga-ee9242a9b5ee69821c1dd8de258ecfd6ad616802.tar.lz
varuga-ee9242a9b5ee69821c1dd8de258ecfd6ad616802.zip
Ask user before modifying accepted MML content type parameters.
* varuga.el: Remove mutation of mml-content-type-parameters.
(varuga--mml-content-type-confirmed): New variable.
(varuga-mml-content-type-confirm): New function.
(varuga-invite): Call varuga-mml-content-type-confirm.

Signed-off-by: Arun Isaac <arunisaac@systemreboot.net>
-rw-r--r--varuga.el27
1 files changed, 23 insertions, 4 deletions
diff --git a/varuga.el b/varuga.el
index 9df5204..eb8ecef 100644
--- a/varuga.el
+++ b/varuga.el
@@ -51,10 +51,6 @@
 (require 'org-id)
 (require 'time)
 
-;; We use the `method' parameter in our text/calendar MIME part; allow
-;; it.
-(add-to-list 'mml-content-type-parameters 'method)
-
 (cl-defstruct (varuga-calendar (:constructor varuga-calendar)
                                (:copier nil))
   components)
@@ -80,6 +76,10 @@
 (defvar varuga-time-format
   world-clock-time-format)
 
+(defvar varuga--mml-content-type-confirmed nil
+  "t if we've already asked the user whether to configure
+`mml-content-type-parameters' for RSVP support, nil otherwise.")
+
 (defun varuga-insert-calendar-line (key value &optional params)
   "Insert ical calendar line.
 KEY is the name of the ical property and VALUE is its value.
@@ -163,6 +163,24 @@ PARAMS is an alist of ical property parameters and their values."
   (or (message-fetch-field "Subject")
       ""))
 
+(defun varuga-mml-content-type-confirm ()
+  "Ask the user for permission to modify
+`mml-content-type-parameters' for RSVP support."
+  (when (and (not (memq 'method mml-content-type-parameters))
+             (not varuga--mml-content-type-confirmed)
+             (let ((help-form "\
+This will add 'method to mml-content-type-parameters, which is
+required for RSVPs to work."))
+               (y-or-n-p "Set up RSVP support?")))
+    (if (let ((help-form "\
+This will save the value of mml-content-type-parameters in your
+`custom-file', so future sessions will support RSVP without
+prompting you."))
+          (y-or-n-p "Support RSVP in future sessions?"))
+        (customize-push-and-save 'mml-content-type-parameters '(method))
+      (add-to-list 'mml-content-type-parameters 'method))
+    (setq varuga--mml-content-type-confirmed t)))
+
 ;;;###autoload
 (defun varuga-invite (summary location when duration)
   "Insert calendar invitation into current email message buffer.
@@ -178,6 +196,7 @@ is the length of the event in minutes."
                      (org-read-date t t nil "When?")
                      (org-duration-to-minutes
                       (read-string "Duration: " "1h"))))
+  (varuga-mml-content-type-confirm)
   (save-excursion
     ;; Fill Subject header if it is blank.
     (when (string-blank-p (varuga-message-subject))