emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-mime d52a7b52b6 114/118: fixed revert plain text email


From: ELPA Syncer
Subject: [nongnu] elpa/org-mime d52a7b52b6 114/118: fixed revert plain text email bug
Date: Wed, 5 Jan 2022 07:58:51 -0500 (EST)

branch: elpa/org-mime
commit d52a7b52b652bb87a82be02f66ba14d54dee0cb5
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    fixed revert plain text email bug
---
 org-mime.el            |  4 +++-
 test/org-mime-tests.el | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/org-mime.el b/org-mime.el
index 8edc2e67bd..18ee99f33c 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -850,7 +850,7 @@ Following headline properties can determine the mail 
headers.
 (defun org-mime-revert-to-plain-text-mail ()
   "Revert mail body to plain text."
   (interactive)
-  (let* ((txt-sep "<#part type=text/plain")
+  (let* ((txt-sep "<#part type=text/plain>")
          (html-sep "<#part type=text/html>")
          mail-beg
          mail-text
@@ -868,6 +868,8 @@ Following headline properties can determine the mail 
headers.
                                                       (- txt-end (length 
html-sep))))
       ;; delete html mail
       (delete-region mail-beg (point-max))
+      (when org-mime-debug
+        (message "mail-beg=%s mail-text=%s" mail-beg mail-text))
       ;; restore text mail
       (insert mail-text))
      (t
diff --git a/test/org-mime-tests.el b/test/org-mime-tests.el
index ff99255165..6a17aeac84 100644
--- a/test/org-mime-tests.el
+++ b/test/org-mime-tests.el
@@ -317,4 +317,22 @@
     (should (string= (nth 0 (plist-get tags :secure-tags))
                      "<#secure method=pgpmime mode=sign>"))))
 
+(ert-deftest test-org-mime-revert-to-plain-text ()
+  (with-temp-buffer
+    (insert
+     "--text follows this line--"
+     "<#multipart type=alternative>\n"
+     "<#part type=text/plain>\n"
+     "test\n"
+     "hello\n"
+     "<#part type=text/html>\n"
+     "<p>\n"
+     "test\n"
+     "hello\n"
+     "</p>\n"
+     "<#/multipart>\n")
+    (message-mode)
+    (org-mime-revert-to-plain-text-mail)
+    (should (string= (string-trim (buffer-string))
+                     "--text follows this line--\ntest\nhello"))))
 (ert-run-tests-batch-and-exit)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]