[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime 11965c407f 055/118: rewrite beautify function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime 11965c407f 055/118: rewrite beautify function |
Date: |
Wed, 5 Jan 2022 07:58:46 -0500 (EST) |
branch: elpa/org-mime
commit 11965c407f358a87c8c1d52a3213f1fa855de4ce
Author: Trevor Murphy <trevor.m.murphy@gmail.com>
Commit: Trevor Murphy <trevor.m.murphy@gmail.com>
rewrite beautify function
---
org-mime.el | 83 ++++++++++++++++---------------------------------------------
1 file changed, 21 insertions(+), 62 deletions(-)
diff --git a/org-mime.el b/org-mime.el
index eb35e9abf8..3bf2c80ab7 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -252,77 +252,36 @@ OPTS is export options."
(buffer-string)))))
(vm "?")))
-(defun org-mime-encode-quoted-mail-body ()
- "Please note quoted mail body could be with reply."
- (let* ((b (save-excursion
- (goto-char (point-min))
- (search-forward-regexp "^[^ ]*> ")
- (search-backward-regexp "<p>")
- (line-beginning-position)))
- (e (save-excursion
- (goto-char (point-max))
- (search-backward-regexp "^[^ ]*> ")
- (search-forward-regexp "</p>")
- (line-end-position)))
- (str (format "<div>%s</div>" (buffer-substring-no-properties b e)))
- (paragraphs (xml-node-children (car (with-temp-buffer
- (insert str)
- (xml--parse-buffer nil nil)))))
- (is-quoted t)
- lines
- (rlt "<blockquote class=\"gmail_quote\" style=\"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex\">\n<p>\n"))
- (dolist (p paragraphs)
- (when (and p (> (length p) 2))
- (dolist (s p)
- (when (and s
- (not (eq s 'p))
- (not (consp s))
- (not (string= s "\n")))
- ;; trim string
- (setq s (replace-regexp-in-string "\\`[ \t\n]*" ""
(replace-regexp-in-string "[ \t\n]*\\'" "" s)))
- (setq lines (split-string s "\n"))
- (dolist (l lines)
- (cond
- ((string-match "^ *[^ ]*> ?\\(.*\\)" l)
- (when (not is-quoted)
- (setq rlt (concat rlt "</p>\n<blockquote
class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex\">\n<p>\n"))
- (setq is-quoted t))
- (setq rlt (concat rlt (match-string 1 l) "<br />\n")))
- ((string= l "")
- (set rlt (concat rlt "<br />")))
- (t
- (when is-quoted
- (setq rlt (concat rlt "</p>\n</blockquote>\n<p>\n"))
- (setq is-quoted nil))
- (setq rlt (concat rlt l "\n")))))))))
- (setq rlt (concat rlt (if is-quoted "</p>\n</blockquote>\n" "</p>\n")))
- (list b e rlt )))
-
(defun org-mime-beautify-quoted (html)
"Clean up quoted mail in modern UI style.
HTML is the body of the message."
- (let* (info)
+ (let ((quote-depth 0)
+ (line-depth 0)
+ (quote-opening "<blockquote class=\"gmail_quote\" style=\"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex\">\n<p>\n")
+ (quote-closing "</p>\n</blockquote>\n"))
(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))
- (unwind-protect
- (let (retval)
- (condition-case ex
- (setq info (org-mime-encode-quoted-mail-body))
- (setq retval info)
- ('error (setq info nil)))
- retval))
- (cond
- (info
- (delete-region (nth 0 info) (nth 1 info))
- (goto-char (nth 0 info))
- (insert (nth 2 info))
- (buffer-substring-no-properties (point-min) (point-max)))
- (t
- html)))))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (setq line-depth 0)
+ (while (looking-at ">[ \t]*")
+ (replace-match "")
+ (cl-incf line-depth))
+ (cond
+ ((< quote-depth line-depth)
+ (while (< quote-depth line-depth)
+ (insert quote-opening)
+ (cl-incf quote-depth)))
+ ((> quote-depth line-depth)
+ (while (> quote-depth line-depth)
+ (insert quote-closing)
+ (cl-decf quote-depth))))
+ (forward-line))
+ (buffer-substring (point-min) (point-max)))))
(defun org-mime-multipart (plain html &optional images)
"Markup a multipart/alternative PLAIN with PLAIN and HTML alternatives.
- [nongnu] elpa/org-mime 351b233a7e 018/118: Don't use obsoleted function, (continued)
- [nongnu] elpa/org-mime 351b233a7e 018/118: Don't use obsoleted function, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 44e7a78ffd 019/118: Fix for cl-lib, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime dfe41e05e2 012/118: Merge pull request #1 from acowley/subject, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime d3ae6df753 013/118: Merge pull request #2 from acowley/subtree, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 957bb3b43a 014/118: Merge pull request #3 from acowley/plain-part, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime b00d23aa1d 022/118: explicitly require org export libs, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime d540da37df 026/118: make it emacs 24.3 compatible, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime c0e99cfdfa 028/118: README, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime f1175e3fab 035/118: can htmlize new mail, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 895a7c31bb 052/118: Merge pull request #23 from liujoey/master, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 11965c407f 055/118: rewrite beautify function,
ELPA Syncer <=
- [nongnu] elpa/org-mime cf7dbea171 054/118: rename cleanup function to match beautify user option, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 53e0c8141b 058/118: one-line fix for klipse errors in org-mime, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime baa6cde22f 057/118: Merge pull request #25 from tmurph/blockquote-parser, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 1b516d604a 056/118: remove unnecessary dependency, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 817744f3b1 062/118: remove plain text body, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 4bd5d55ba9 071/118: fixed logic, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime dd9dac74cc 073/118: doc on html export, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime d827dbfb97 077/118: Add option to export ASCII for text/plain section, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3596bbfe10 079/118: Fix: #36 Add ASCII export for org-mime-htmlize, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3974bd4190 093/118: make checkdoc happy, ELPA Syncer, 2022/01/05