[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime df99e631c5 031/118: quoted mail use modern UI sty
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime df99e631c5 031/118: quoted mail use modern UI style |
Date: |
Wed, 5 Jan 2022 07:58:44 -0500 (EST) |
branch: elpa/org-mime
commit df99e631c557b892f9d632d938d37ab9e9b2b1ae
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
quoted mail use modern UI style
---
README.org | 2 +-
org-mime.el | 44 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/README.org b/README.org
index 02f058129a..86452548d0 100644
--- a/README.org
+++ b/README.org
@@ -20,7 +20,7 @@ Tested on Emacs 24.3, 24.4, 24.5, 25.1, 25.2
Export a portion of an email body composed using `mml-mode' to html using
`org-mode'. If called with an active region only export that region, otherwise
export the entire body.
-Warning: There has been some concern voiced over the potential complexity of
email resulting from calling this function on an active region resulting in
multiple =multipart/alternative= sections in the same email. Please see this
email thread for a discussion of the potential pitfalls of this approach.
Speaking from personal experience this has not been a problem for the author.
+Warning: There has been some concern voiced over the potential complexity of
email resulting from calling this function on an active region resulting in
multiple =multipart/alternative= sections in the same email. Please see
[[http://thread.gmane.org/gmane.emacs.orgmode/23617][this email thread]] for a
discussion of the potential pitfalls of this approach. Speaking from personal
experience this has not been a problem for the author.
** =M-x org-mime-org-buffer-htmlize=
=org-mime-org-buffer-htmlize= can be called from within an Org-mode buffer to
export either the whole buffer or the narrowed subtree or active region to
HTML, and open a new email buffer including the resulting HTML content as an
embedded mime section.
diff --git a/org-mime.el b/org-mime.el
index ca8d05d149..9c42802db1 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -6,8 +6,8 @@
;; Maintainer: Chen Bin (redguardtoo)
;; Keywords: mime, mail, email, html
;; Homepage: http://github.com/org-mime/org-mime
-;; Version: 0.0.7
-;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
+;; Version: 0.0.8
+;; Package-Requires: ((emacs "24.3") (cl-lib "0.5"))
;; This file is not part of GNU Emacs.
@@ -91,11 +91,19 @@
;; (lambda ()
;; (while (re-search-forward "@\\([^@]*\\)@" nil t)
;; (replace-match "<span style=\"color:red\">\\1</span>"))))
+;;
+;; 3. Since v0.0.8, the quoted mail use modern style (like Gmail). If you
prefer
+;; the original style, please set `org-mime-beautify-quoted-mail' to nil.
;;; Code:
(require 'cl-lib)
(require 'org)
+(defcustom org-mime-beautify-quoted-mail t
+ "Beautify quoted mail in more clean HTML, like Gmail."
+ :group 'org-mime
+ :type 'boolean)
+
(defcustom org-mime-use-property-inheritance nil
"Non-nil means al MAIL_ properties apply also for sublevels."
:group 'org-mime
@@ -215,6 +223,34 @@ You could use either `org-up-heading-safe' or
`org-back-to-heading'.")
(buffer-string)))))
(vm "?")))
+(defun org-mime-cleanup-quoted (html)
+ "Clean up quoted mail in modern UI style."
+ (cond
+ (org-mime-beautify-quoted-mail
+ (with-temp-buffer
+ ;; clean title of quoted
+ (insert (replace-regexp-in-string
+ "<p>[\n\r]*>>>>> .* == \\([^\r\n]*\\)[\r\n]*</p>"
+ "<div class=\"gmail_quote\">\\1</div>"
+ html))
+ ;; now handle body, try to find beginning
+ (goto-char (point-min))
+ (search-forward-regexp "^[^ ]*> ")
+ (search-backward-regexp "<p>")
+ ;; gmail use this style
+ (insert "<blockquote class=\"gmail_quote\" style=\"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex\">\n")
+ ;; find end
+ (goto-char (point-max))
+ (search-backward-regexp "^[^ ]*> ")
+ (search-forward-regexp "</p>")
+ (goto-char (+ (point) 1))
+ (insert "</blockquote>")
+ (setq html (buffer-substring-no-properties (point-min) (point-max))))
+ ;; remove "User> "
+ (replace-regexp-in-string "^ *[^ ]*> " "" html))
+ (t
+ html)))
+
(defun org-mime-multipart (plain html &optional images)
"Markup a multipart/alternative PLAIN with PLAIN and HTML alternatives.
If html portion of message includes IMAGES they are wrapped in
multipart/related part."
@@ -223,7 +259,7 @@ If html portion of message includes IMAGES they are wrapped
in multipart/related
plain
(when images "<#multipart type=related>")
"<#part type=text/html>"
- html
+ (org-mime-cleanup-quoted html)
images
(when images "<#/multipart>\n")
"<#/multipart>\n"))
@@ -385,7 +421,7 @@ and in org formats as mime alternatives."
(interactive)
(save-excursion
(funcall org-mime-up-subtree-heading)
- (flet ((mp (p) (org-entry-get nil p org-mime-use-property-inheritance)))
+ (cl-flet ((mp (p) (org-entry-get nil p org-mime-use-property-inheritance)))
(let* ((file (buffer-file-name (current-buffer)))
(subject (or (mp "MAIL_SUBJECT") (nth 4
(org-heading-components))))
(to (mp "MAIL_TO"))
- [nongnu] elpa/org-mime 9bb6351b25 085/118: un-bundled htmlize.el, (continued)
- [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
- [nongnu] elpa/org-mime 04e6ce9db6 108/118: try fixing ci again, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime eb21c02ba8 109/118: fixed org subtree htmlize, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 21692f16ce 110/118: use buffer properties, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 59bf130c76 113/118: secure tag should be at the beginning of email body, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime df99e631c5 031/118: quoted mail use modern UI style,
ELPA Syncer <=
- [nongnu] elpa/org-mime e5e4c59022 103/118: fixed some typo, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3b119a22be 112/118: handle file url on Windows elegantly, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime f7a45f5573 115/118: Upgrade test file to GPLv3, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 77c3f07ce4 046/118: documentation, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e5c68b1c66 044/118: minor changes to docstrings for readability and style changes., ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e35c367e7d 048/118: clean code, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 41ea9818b4 050/118: fix cc, bcc compiling error, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 0db41d5b4e 065/118: emergency fix of broken 0.1.4, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 470808cc14 070/118: Added support for MAIL_FROM property, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 5132ec0586 089/118: Improve signature separator regex, ELPA Syncer, 2022/01/05