[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime f8eac8ccde 066/118: restore plain text mail
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime f8eac8ccde 066/118: restore plain text mail |
Date: |
Wed, 5 Jan 2022 07:58:47 -0500 (EST) |
branch: elpa/org-mime
commit f8eac8ccdec2ebf1dec87d4f5f01b4b53f86c67c
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
restore plain text mail
---
README.org | 2 +-
org-mime.el | 89 +++++++++++++++++++++++++++++++------------------------------
2 files changed, 46 insertions(+), 45 deletions(-)
diff --git a/README.org b/README.org
index e1e74a3375..97c1761d01 100644
--- a/README.org
+++ b/README.org
@@ -1,4 +1,4 @@
-* org-mime v0.1.5
+* org-mime v0.1.6
[[https://travis-ci.org/org-mime/org-mime][https://travis-ci.org/org-mime/org-mime.svg?branch=master]]
[[http://melpa.org/#/org-mime][file:http://melpa.org/packages/org-mime-badge.svg]]
[[http://stable.melpa.org/#/org-mime][file:http://stable.melpa.org/packages/org-mime-badge.svg]]
diff --git a/org-mime.el b/org-mime.el
index 009c8cab53..2eadbae042 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -6,7 +6,7 @@
;; Maintainer: Chen Bin (redguardtoo)
;; Keywords: mime, mail, email, html
;; Homepage: http://github.com/org-mime/org-mime
-;; Version: 0.1.5
+;; Version: 0.1.6
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
;; This file is not part of GNU Emacs.
@@ -185,29 +185,28 @@ buffer holding the text to be exported.")
(buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
-(defun org-mime-get-exported-content (subtreep)
+(defun org-mime-export-buffer-or-subtree (subtreep)
"Similar to `org-html-export-as-html' and `org-org-export-as-org'.
SUBTREEP is t if current node is subtree."
- (let* ((buf (org-export-to-buffer 'html "*Org Mime Export*"
+ (let* ((plain (buffer-string))
+ (buf (org-export-to-buffer 'html "*Org Mime Export*"
nil subtreep nil (org-mime-get-export-options subtreep)))
(body (prog1
(with-current-buffer buf
- (format "#+BEGIN_EXPORT html\n%s\n#+END_EXPORT"
- (buffer-string)))
+ (buffer-string))
(kill-buffer buf))))
- body))
+ (cons body plain)))
-(defun org-mime--export-string (s fmt &optional opts)
- "Export string S using FMT as the backend.
+(defun org-mime-export-string (string &optional opts)
+ "Export STRING into html.
OPTS is export options."
;; Emacs 25+ prefer exporting drawer by default
;; obviously not acceptable in exporting to mail body
(let* ((org-export-with-drawers nil))
- (when org-mime-debug (message "org-mime--export-string called => %s" opts))
;; we won't export title from org file anyway
(if opts (setq opts (plist-put opts 'title nil)))
;; emacs24.4+
- (org-export-string-as s fmt t (or org-mime-export-options opts))))
+ (org-export-string-as string 'html t (or org-mime-export-options opts))))
;; example hook, for setting a dark background in
;; <pre style="background-color: #EEE;"> elements
@@ -278,11 +277,12 @@ HTML is the body of the message."
(forward-line))
(buffer-substring (point-min) (point-max)))))
-(defun org-mime-multipart (html &optional images)
+(defun org-mime-multipart (plain html &optional images)
"Markup a multipart/alternative with HTML alternatives.
If html portion of message includes IMAGES they are wrapped in
multipart/related part."
(cl-case org-mime-library
- (mml (concat "<#multipart type=alternative>"
+ (mml (concat "<#multipart type=alternative>\n<#part type=text/plain>"
+ plain
(when images "<#multipart type=related>")
"<#part type=text/html>"
(if org-mime-beautify-quoted-mail
@@ -293,6 +293,7 @@ If html portion of message includes IMAGES they are wrapped
in multipart/related
"<#/multipart>\n"))
(semi (concat
"--" "<<alternative>>-{\n"
+ "--" "[[text/plain]]\n" plain
(when images (concat "--" "<<alternative>>-{\n"))
"--" "[[text/html]]\n" html
images
@@ -356,7 +357,8 @@ CURRENT-FILE is used to calculate full path of images."
(message "Warning: org-element-map is not available. File links will not
be attached.")
nil)))
-(defun org-mime-insert-html-content (body file s opts)
+(defun org-mime-insert-html-content (plain file html opts)
+ "Insert HTML content."
(let* ((files (org-mime-extract-non-image-files))
;; dvipng for inline latex because MathJax doesn't work in mail
;; Also @see https://github.com/org-mime/org-mime/issues/16
@@ -365,14 +367,13 @@ CURRENT-FILE is used to calculate full path of images."
;; we don't want to convert org file links to html
(org-html-link-org-files-as-html nil)
(org-link-file-path-type 'absolute)
- ;; makes the replies with ">"s look nicer
+ ;; prettify reply with ">"
(org-export-preserve-breaks org-mime-preserve-breaks)
;; org 9
(org-html-htmlize-output-type 'inline-css)
;; org 8
(org-export-htmlize-output-type 'inline-css)
- (html-and-images (org-mime-replace-images (org-mime--export-string s
'html opts)
- file))
+ (html-and-images (org-mime-replace-images html file))
(images (cdr html-and-images))
(html (org-mime-apply-html-hook (car html-and-images))))
@@ -387,7 +388,9 @@ CURRENT-FILE is used to calculate full path of images."
html)))
files))
- (insert (org-mime-multipart html (if images (mapconcat 'identity images
"\n"))))
+ (insert (org-mime-multipart plain
+ html
+ (if images (mapconcat 'identity images "\n"))))
;; Attach any residual files
(when files
@@ -412,22 +415,19 @@ If called with an active region only export that region,
otherwise entire body."
(html-end (or (and region-p (region-end))
;; TODO: should catch signature...
(point-max)))
- (body (buffer-substring
- html-start html-end))
- (str (concat org-mime-default-header body))
- (file (make-temp-name (expand-file-name
- "mail" temporary-file-directory)))
-
-
- ;; to hold attachments for inline html images
+ (plain (buffer-substring html-start html-end))
+;; to hold attachments for inline html images
(opts (if (fboundp 'org-export--get-inbuffer-options)
- (org-export--get-inbuffer-options))))
+ (org-export--get-inbuffer-options)))
+ (html (org-mime-export-string (concat org-mime-default-header plain)
opts))
+ (file (make-temp-name (expand-file-name
+ "mail" temporary-file-directory))))
;; delete current region
(delete-region html-start html-end)
(goto-char html-start)
;; insert new current
- (org-mime-insert-html-content body file str opts)))
+ (org-mime-insert-html-content plain file html opts)))
(defun org-mime-apply-html-hook (html)
"Apply HTML hook."
@@ -448,23 +448,24 @@ If called with an active region only export that region,
otherwise entire body."
(set-text-properties 0 (length txt) nil txt)
txt))))
-(defun org-mime-compose (body file to subject headers subtreep)
- "Create mail BODY in FILE with TO, SUBJECT, HEADERS.
+(defun org-mime-compose (exported file to subject headers subtreep)
+ "Create mail body from EXPORTED in FILE with TO, SUBJECT, HEADERS.
If SUBTREEP is t, curret org node is subtree."
;; start composing mail
- (let* ((export-opts (org-mime-get-export-options subtreep))
- str)
- (unless (featurep 'message)
- (require 'message))
+ (let* ((html (car exported))
+ (plain (cdr exported))
+ (export-opts (org-mime-get-export-options subtreep))
+ patched-html)
+ (unless (featurep 'message) (require 'message))
(message-mail to subject headers nil)
(message-goto-body)
- (setq str (with-temp-buffer
- (insert body)
- (goto-char (point-min))
- (run-hooks 'org-mime-pre-html-hook)
- (buffer-string)))
+ (setq patched-html (with-temp-buffer
+ (insert html)
+ (goto-char (point-min))
+ (run-hooks 'org-mime-pre-html-hook)
+ (buffer-string)))
;; insert text
- (org-mime-insert-html-content body file str export-opts)))
+ (org-mime-insert-html-content plain file patched-html export-opts)))
(defun org-mime-extract-keywords ()
"Extract keywords."
@@ -515,12 +516,12 @@ The cursor ends in the TO field."
(if (not file) (buffer-name (buffer-base-buffer))
(file-name-sans-extension
(file-name-nondirectory file)))))
- (html-body (org-mime-get-exported-content nil))
+ (exported (org-mime-export-buffer-or-subtree nil))
(to (cdr (assoc "MAIL_TO" keywords)))
(cc (cdr (assoc "MAIL_CC" keywords)))
(bcc (cdr (assoc "MAIL_BCC" keywords)))
(other-headers (org-mime-build-mail-other-headers cc bcc)))
- (org-mime-compose html-body file to subject other-headers nil)
+ (org-mime-compose exported file to subject other-headers nil)
(message-goto-to)))
(defun org-mime-org-major-version ()
@@ -571,11 +572,11 @@ Following headline properties can determine the mail
headers,
;; I wrap these bodies in export blocks because in
org-mime-compose
;; they get exported again. This makes each block conditionally
;; exposed depending on the backend.
- (html-body (save-restriction (org-narrow-to-subtree)
- (org-mime-get-exported-content t))))
+ (exported (save-restriction (org-narrow-to-subtree)
+ (org-mime-export-buffer-or-subtree
t))))
(save-restriction
(org-narrow-to-subtree)
- (org-mime-compose html-body file to subject other-headers t))
+ (org-mime-compose exported file to subject other-headers t))
(message-goto-to)))))
(provide 'org-mime)
- [nongnu] elpa/org-mime 3974bd4190 093/118: make checkdoc happy, (continued)
- [nongnu] elpa/org-mime 3974bd4190 093/118: make checkdoc happy, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime b47811562b 099/118: Merge pull request #52 from tomheon/fix-gmail-quoting, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 4580e345cb 102/118: add emacs 27 ci, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 0caaf273e7 011/118: Use a plain ASCII export for the text part, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 62791db188 033/118: beautify quoted mail properly, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 7a6dae2494 039/118: Lisp error: (error "Too many arguments") – should be defcustom, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime b9def25bf4 043/118: Edit docstrings for checkdoc compatibility., ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 6593522166 051/118: Fix: #22, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime ea7a470872 061/118: add badge, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 8de4bb693d 064/118: image could be nil, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime f8eac8ccde 066/118: restore plain text mail,
ELPA Syncer <=
- [nongnu] elpa/org-mime 95c33ec353 067/118: add screenshot, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 562cb5a3f0 074/118: Use compose-mail, rather than explicitly using message-mail, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 7475a592c2 081/118: drop emacs 24 support, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e81651d848 084/118: clean code, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 9bb6351b25 085/118: un-bundled htmlize.el, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 2581fc2dd9 091/118: org-mime-confirm-when-no-multipart function + docs, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 8ad1218456 095/118: Combine two insert calls, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 2cbd5de7bd 100/118: general export options should always override buffer options, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime ecbc66f16a 106/118: fixed typo, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime c6a3d73e78 107/118: remove org-mime-default-header, ELPA Syncer, 2022/01/05