[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime f610861858 063/118: htmlize current subtree
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime f610861858 063/118: htmlize current subtree |
Date: |
Wed, 5 Jan 2022 07:58:47 -0500 (EST) |
branch: elpa/org-mime
commit f61086185819cc36dcfdfa0b49aac5fd557ff815
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
htmlize current subtree
---
org-mime.el | 75 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 40 insertions(+), 35 deletions(-)
diff --git a/org-mime.el b/org-mime.el
index 391fabcfa6..b6a86aec1c 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -42,13 +42,10 @@
;; encoding.
;;
;; `org-mime-org-subtree-htmlize' is similar to `org-mime-org-buffer-htmlize'
-;; but works on a subtree. It can also read the following subtree properties:
-;; MAIL_SUBJECT, MAIL_TO, MAIL_CC, and MAIL_BCC. Note the behavior of this is
-;; controlled by `org-mime-up-subtree-heading'. The default is to go up to the
-;; heading containing the current subtree.
-
-;; Here is the sample of a subtree:
+;; but works on current subtree. It can read following subtree properties:
+;; MAIL_SUBJECT, MAIL_TO, MAIL_CC, and MAIL_BCC.
;;
+;; Here is the sample of a subtree:
;; * mail one
;; :PROPERTIES:
;; :MAIL_SUBJECT: mail title
@@ -104,6 +101,7 @@
;;; Code:
(require 'cl-lib)
+(require 'outline)
(require 'org)
(require 'ox-org)
@@ -170,11 +168,6 @@ buffer holding the text to be exported.")
(defvar org-mime-debug nil
"Enable debug logger.")
-(defvar org-mime-up-subtree-heading 'org-up-heading-safe
- "Function to call before exporting a subtree.
-You could use either `org-up-heading-safe' or `org-back-to-heading'.")
-
-
(defun org-mime-get-export-options (subtreep)
"SUBTREEP is t if current node is subtree."
(cond
@@ -187,6 +180,11 @@ You could use either `org-up-heading-safe' or
`org-back-to-heading'.")
(if (fboundp 'org-export--get-inbuffer-options)
(org-export--get-inbuffer-options))))))
+(defun org-mime-current-line ()
+ "Get current line"
+ (buffer-substring-no-properties (line-beginning-position)
+ (line-end-position)))
+
(defun org-mime-get-exported-content (subtreep)
"Similar to `org-html-export-as-html' and `org-org-export-as-org'.
SUBTREEP is t if current node is subtree."
@@ -529,32 +527,40 @@ The cursor ends in the TO field."
"Get Org major version."
(string-to-number (car (split-string (org-release) "\\."))))
-;; TODO integrating patch
+(defun org-mime-attr (p)
+ (org-entry-get nil p org-mime-use-property-inheritance))
+
;;;###autoload
-(defun org-mime-org-subtree-htmlize ()
- "Create an email buffer of the current subtree.
-The buffer will contain both html and in org formats as mime
-alternatives.
+(defun org-mime-org-subtree-htmlize (&optional htmlize-first-level)
+ "Create an email buffer of the current subtree. If HTMLIZE-FIRST-LEVEL is
+not nil, the first level subtree which containing current subtree is htmlized.
-The following headline properties can determine the headers.
+Following headline properties can determine the mail headers,
* subtree heading
- :PROPERTIES:
- :MAIL_SUBJECT: mail title
- :MAIL_TO: person1@gmail.com
- :MAIL_CC: person2@gmail.com
- :MAIL_BCC: person3@gmail.com
- :END:
-
-The cursor is left in the TO field."
- (interactive)
+ :PROPERTIES:
+ :MAIL_SUBJECT: mail title
+ :MAIL_TO: person1@gmail.com
+ :MAIL_CC: person2@gmail.com
+ :MAIL_BCC: person3@gmail.com
+ :END:
+"
+ (interactive "P")
(save-excursion
- (funcall org-mime-up-subtree-heading)
- (cl-flet ((mp (p) (org-entry-get nil p org-mime-use-property-inheritance)))
+ (org-back-to-heading)
+
+ (when (and htmlize-first-level
+ (not (string-match "^\\* " (org-mime-current-line))))
+ ;; go back to the 1st level substree
+ (re-search-backward "^\\* ")
+ (org-back-to-heading))
+
+ (when (outline-on-heading-p nil)
(let* ((file (buffer-file-name (current-buffer)))
- (subject (or (mp "MAIL_SUBJECT") (nth 4
(org-heading-components))))
- (to (mp "MAIL_TO"))
- (cc (mp "MAIL_CC"))
- (bcc (mp "MAIL_BCC"))
+ (subject (or (org-mime-attr "MAIL_SUBJECT")
+ (nth 4 (org-heading-components))))
+ (to (org-mime-attr "MAIL_TO"))
+ (cc (org-mime-attr "MAIL_CC"))
+ (bcc (org-mime-attr "MAIL_BCC"))
;; Thanks to Matt Price improving handling of cc & bcc headers
(other-headers (org-mime-build-mail-other-headers cc bcc))
(org-export-show-temporary-export-buffer nil)
@@ -565,9 +571,8 @@ The cursor is left in the TO field."
;; 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))))
+ (html-body (save-restriction (org-narrow-to-subtree)
+ (org-mime-get-exported-content t))))
(save-restriction
(org-narrow-to-subtree)
(org-mime-compose html-body file to subject other-headers t))
- [nongnu] elpa/org-mime 91d8f48775 023/118: can set org export options, (continued)
- [nongnu] elpa/org-mime 91d8f48775 023/118: can set org export options, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 7c3483b2b0 030/118: sample for advanced setup, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e3329c7c4d 032/118: README, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 0a0aa9b110 034/118: README, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime ad30f199cb 036/118: provide org-mime-find-html-start callback, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 5f253f541c 037/118: only use export header when creating html, keep out of email, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime c6e2b95664 047/118: clean code, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 64a3f56651 041/118: (setq org-html-with-latex nil) sometimes useful #16, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 10098b001c 049/118: Fix file attachments and equations and enhance emails from org-files, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 1e792ef061 059/118: Merge pull request #28 from titaniumbones/fix-klipse-error, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime f610861858 063/118: htmlize current subtree,
ELPA Syncer <=
- [nongnu] elpa/org-mime 9506727ca7 072/118: README, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime b189976217 076/118: fixed CI, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 778f818ad3 078/118: Add ASCII text/plain export test, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 9f84446038 082/118: make emacs 25 test pass, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 484bf3b0b8 083/118: can edit mail-body in org-mode buffer directly, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 5980ccaace 080/118: fixed unit test, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime b129579986 087/118: Regexp search for sig sep, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 30bb3e663d 117/118: Merge pull request #66 from skangas/gplv3, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 4105d1bb9c 004/118: support Emacs 23.4, 24.3 24.4, 24.5, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e9b0be2860 005/118: mails need NO TOC, ELPA Syncer, 2022/01/05