[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime 4105d1bb9c 004/118: support Emacs 23.4, 24.3 24.4
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime 4105d1bb9c 004/118: support Emacs 23.4, 24.3 24.4, 24.5 |
Date: |
Wed, 5 Jan 2022 07:58:41 -0500 (EST) |
branch: elpa/org-mime
commit 4105d1bb9ca3712f403f5c47c1ec1c74f3749f0e
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
support Emacs 23.4, 24.3 24.4, 24.5
- remove ascii, org export (24.4+ issue)
- `org-export-as-string` only use hard coded parameter (24.4+ issue)
---
org-mime.el | 152 +++++++++++++++++++-----------------------------------------
1 file changed, 48 insertions(+), 104 deletions(-)
diff --git a/org-mime.el b/org-mime.el
index d9e14d1fd7..20d903b408 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/redguardtoo/org-mime
-;; Version: 0.0.2
+;; Version: 0.0.3
;; This file is not part of GNU Emacs.
@@ -59,13 +59,10 @@
;; (local-set-key (kbd "C-c M-o") 'org-mime-org-buffer-htmlize)))
;;; Code:
-(require 'cl)
-(require 'org)
+(eval-when-compile
+ (require 'cl))
-(defcustom org-mime-use-property-inheritance nil
- "Non-nil means al MAIL_ properties apply also for sublevels."
- :group 'org-mime
- :type 'boolean)
+(require 'org)
(defcustom org-mime-default-header
"#+OPTIONS: latex:t\n"
@@ -91,33 +88,24 @@
:group 'org-mime
:type 'string)
-(defcustom org-mime-html-hook nil
+(defvar org-mime-html-hook nil
"Hook to run over the html buffer before attachment to email.
- This could be used for example to post-process html elements."
- :group 'org-mime
- :type 'hook)
+This could be used for example to post-process html elements.")
-(mapc (lambda (fmt)
- (eval `(defcustom
- ,(intern (concat "org-mime-pre-" fmt "-hook"))
- nil
- (concat "Hook to run before " fmt " export.\nFunctions "
- "should take no arguments and will be run in a "
- "buffer holding\nthe text to be exported."))))
- '("ascii" "org" "html"))
+(defvar org-mime-pre-html-hook nil
+ "Hook to run before html export.
+Functions should take no arguments and will be run in a
+buffer holding\nthe text to be exported.")
-(defcustom org-mime-send-subtree-hook nil
- "Hook to run in the subtree in the Org-mode file before export.")
-
-(defcustom org-mime-send-buffer-hook nil
+(defvar org-mime-send-buffer-hook nil
"Hook to run in the Org-mode file before export.")
-(defun org-mime--export-string (s fmt)
+(defun org-mime--export-string (s)
(if (fboundp 'org-export-string-as)
- ;; emacs23
- (org-export-string-as s (make-symbol fmt) t)
- ;; emacs 24
- (org-export-string s fmt)))
+ ;; emacs24
+ (org-export-string-as s 'html t)
+ ;; emacs 23
+ (org-export-string s "html")))
;; example hook, for setting a dark background in <pre
style="background-color: #EEE;"> elements
(defun org-mime-change-element-style (element style)
@@ -216,11 +204,10 @@ export that region, otherwise export the entire body."
(html-end (or (and region-p (region-end))
;; TODO: should catch signature...
(point-max)))
- (raw-body (concat org-mime-default-header
+ (body (concat org-mime-default-header
(buffer-substring html-start html-end)))
(tmp-file (make-temp-name (expand-file-name
"mail" temporary-file-directory)))
- (body (org-mime--export-string raw-body "org"))
;; because we probably don't want to export a huge style file
(org-export-htmlize-output-type 'inline-css)
;; makes the replies with ">"s look nicer
@@ -230,7 +217,7 @@ export that region, otherwise export the entire body."
;; to hold attachments for inline html images
(html-and-images
(org-mime-replace-images
- (org-mime--export-string raw-body "html") tmp-file))
+ (org-mime--export-string body) tmp-file))
(html-images (unless arg (cdr html-and-images)))
(html (org-mime-apply-html-hook
(if arg
@@ -254,28 +241,7 @@ export that region, otherwise export the entire body."
(defmacro org-mime-try (&rest body)
`(condition-case nil ,@body (error nil)))
-(defun org-mime-send-subtree (&optional fmt)
- (save-restriction
- (org-narrow-to-subtree)
- (run-hooks 'org-mime-send-subtree-hook)
- (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"))
- (cc (mp "MAIL_CC"))
- (bcc (mp "MAIL_BCC"))
- (body (buffer-substring
- (save-excursion (goto-char (point-min))
- (forward-line 1)
- (when (looking-at "[ \t]*:PROPERTIES:")
- (re-search-forward ":END:" nil)
- (forward-char))
- (point))
- (point-max))))
- (org-mime-compose body (or fmt 'org) file to subject
- `((cc . ,cc) (bcc . ,bcc)))))))
-
-(defun org-mime-send-buffer (&optional fmt)
+(defun org-mime-send-buffer ()
(run-hooks 'org-mime-send-buffer-hook)
(let* ((region-p (org-region-active-p))
(subject (org-export-grab-title-from-buffer))
@@ -285,62 +251,40 @@ export that region, otherwise export the entire body."
(body-end (or (and region-p (region-end)) (point-max)))
(temp-body-file (make-temp-file "org-mime-export"))
(body (buffer-substring body-start body-end)))
- (org-mime-compose body (or fmt 'org) file nil subject)))
-
-(defun org-mime-compose (body fmt file &optional to subject headers)
- (unless (featurep 'message)
- (require 'message))
- (message-mail to subject headers nil)
- (message-goto-body)
- (flet ((bhook (body fmt)
- (let ((hook (intern (concat "org-mime-pre-"
- (symbol-name fmt)
- "-hook"))))
- (if (> (eval `(length ,hook)) 0)
- (with-temp-buffer
- (insert body)
- (goto-char (point-min))
- (eval `(run-hooks ',hook))
- (buffer-string))
- body))))
- (let ((fmt (if (symbolp fmt) fmt (intern fmt))))
- (cond
- ((eq fmt 'org)
- (insert (org-mime--export-string
- (org-babel-trim (bhook body 'org)) "org")))
- ((eq fmt 'ascii)
- (insert (org-mime--export-string
- (concat "#+Title:\n" (bhook body 'ascii)) "ascii")))
- ((or (eq fmt 'html) (eq fmt 'html-ascii))
- (let* ((org-link-file-path-type 'absolute)
- ;; we probably don't want to export a huge style file
- (org-export-htmlize-output-type 'inline-css)
- (html-and-images
- (org-mime-replace-images
- (org-mime--export-string (bhook body 'html) "html") file))
- (images (cdr html-and-images))
- (html (org-mime-apply-html-hook (car html-and-images))))
- (insert (org-mime-multipart
- (org-mime--export-string
- (org-babel-trim
- (bhook body (if (eq fmt 'html) "org" "ascii")))
- (if (eq fmt 'html) 'org 'ascii) t)
- html)
- (mapconcat 'identity images "\n"))))))))
+ (org-mime-compose body file nil subject)))
+
+(defun org-mime-compose (body file &optional to subject headers)
+ (let* ((fmt 'html))
+ (unless (featurep 'message)
+ (require 'message))
+ (message-mail to subject headers nil)
+ (message-goto-body)
+ (flet ((bhook (body fmt)
+ (let ((hook 'org-mime-pre-html-hook))
+ (if (> (eval `(length ,hook)) 0)
+ (with-temp-buffer
+ (insert body)
+ (goto-char (point-min))
+ (eval `(run-hooks ',hook))
+ (buffer-string))
+ body))))
+ (let* ((org-link-file-path-type 'absolute)
+ ;; we probably don't want to export a huge style file
+ (org-export-htmlize-output-type 'inline-css)
+ (html-and-images
+ (org-mime-replace-images
+ (org-mime--export-string (bhook body 'html)) file))
+ (images (cdr html-and-images))
+ (html (org-mime-apply-html-hook (car html-and-images))))
+ (insert (org-mime-multipart (org-babel-trim body) html)
+ (mapconcat 'identity images "\n"))))))
(defun org-mime-org-buffer-htmlize ()
"Create an email buffer containing the current org-mode file
exported to html and encoded in both html and in org formats as
mime alternatives."
(interactive)
- (org-mime-send-buffer 'html))
-
-(defun org-mime-subtree ()
- "Create an email buffer containing the current org-mode subtree
- exported to a org format or to the format specified by the
- MAIL_FMT property of the subtree."
- (interactive)
- (org-mime-send-subtree
- (or (org-entry-get nil "MAIL_FMT" org-mime-use-property-inheritance) 'org)))
+ (org-mime-send-buffer))
(provide 'org-mime)
+;;; org-mime.el ends here
- [nongnu] elpa/org-mime 1e792ef061 059/118: Merge pull request #28 from titaniumbones/fix-klipse-error, (continued)
- [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, 2022/01/05
- [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 <=
- [nongnu] elpa/org-mime e9b0be2860 005/118: mails need NO TOC, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3a16180195 006/118: clean code according to org-mode review, ELPA Syncer, 2022/01/05
- [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