From ee9242a9b5ee69821c1dd8de258ecfd6ad616802 Mon Sep 17 00:00:00 2001 From: Jake Coble Date: Sun, 15 Jun 2025 20:01:26 -0400 Subject: 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 --- varuga.el | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'varuga.el') 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)) -- cgit v1.2.3