From 4bb577f26b112ef6f5ed1171dee831bae33bb4c9 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Mon, 17 Jun 2024 19:56:32 +0100
Subject: Fill Subject header only if it is blank.

* varuga.el (varuga-invite): Fill Subject header only if it is blank.
---
 varuga.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/varuga.el b/varuga.el
index 1d17779..b7e24c3 100644
--- a/varuga.el
+++ b/varuga.el
@@ -138,14 +138,15 @@ is the length of the event in minutes."
                      (org-duration-to-minutes
                       (read-string "Duration: "))))
   (save-excursion
-    ;; Fill Subject header.
-    (save-restriction
-      (message-narrow-to-headers)
-      (re-search-forward "^Subject:")
-      (message-narrow-to-field)
-      (end-of-line)
-      ;; TODO: Allow customization of the Subject format.
-      (insert (format "Invitation: %s" summary)))
+    ;; Fill Subject header if it is blank.
+    (when (string-blank-p (message-fetch-field "Subject"))
+      (save-restriction
+        (message-narrow-to-headers)
+        (re-search-forward "^Subject:")
+        (message-narrow-to-field)
+        (end-of-line)
+        ;; TODO: Allow customization of the Subject format.
+        (insert (format "Invitation: %s" summary))))
     ;; Fill email body.
     (goto-char (point-max))
     (insert "<#multipart type=mixed>\n")
-- 
cgit v1.2.3