summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-04-06 19:09:38 +0200
committerBastien Guerry <bzg@altern.org>2013-04-06 19:09:38 +0200
commit1e496cc8f9edf4c385128511b3598878d8603b0b (patch)
tree0f07810a0ea1198e0109b84c64368f35bab12088
parent133afe8915193adeb9d6f98a3a139cecc1a7ea66 (diff)
downloadorg-mode-1e496cc8f9edf4c385128511b3598878d8603b0b.tar.gz
ox.el (org-export-replace-region-by): New function
* ox.el (org-export-replace-region-by): New function. * ox-texinfo.el (org-texinfo-convert-region-to-texinfo): * ox-md.el (org-md-convert-region-to-md): * ox-latex.el (org-latex-convert-region-to-latex): * ox-html.el (org-html-convert-region-to-html): New functions to replace the active region by its export into various backends.
-rw-r--r--lisp/ox-html.el9
-rw-r--r--lisp/ox-latex.el9
-rw-r--r--lisp/ox-md.el9
-rw-r--r--lisp/ox-texinfo.el9
-rw-r--r--lisp/ox.el12
5 files changed, 48 insertions, 0 deletions
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index e3495f5..4eabad4 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3194,6 +3194,15 @@ is non-nil."
(switch-to-buffer-other-window outbuf)))))
;;;###autoload
+(defun org-html-convert-region-to-html ()
+ "Assume the current region has org-mode syntax, and convert it to HTML.
+This can be used in any buffer. For example, you can write an
+itemized list in org-mode syntax in an HTML buffer and use this
+command to convert it."
+ (interactive)
+ (org-export-replace-region-by 'html))
+
+;;;###autoload
(defun org-html-export-to-html
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a HTML file.
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index aad9271..9c04695 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2822,6 +2822,15 @@ is non-nil."
(switch-to-buffer-other-window outbuf)))))
;;;###autoload
+(defun org-latex-convert-region-to-latex ()
+ "Assume the current region has org-mode syntax, and convert it to LaTeX.
+This can be used in any buffer. For example, you can write an
+itemized list in org-mode syntax in an LaTeX buffer and use this
+command to convert it."
+ (interactive)
+ (org-export-replace-region-by 'latex))
+
+;;;###autoload
(defun org-latex-export-to-latex
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a LaTeX file.
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 43c92a2..61f42b8 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -455,6 +455,15 @@ non-nil."
(when org-export-show-temporary-export-buffer
(switch-to-buffer-other-window outbuf)))))
+;;;###autoload
+(defun org-md-convert-region-to-md ()
+ "Assume the current region has org-mode syntax, and convert it to Markdown.
+This can be used in any buffer. For example, you can write an
+itemized list in org-mode syntax in a Markdown buffer and use
+this command to convert it."
+ (interactive)
+ (org-export-replace-region-by 'md))
+
;;;###autoload
(defun org-md-export-to-markdown (&optional async subtreep visible-only)
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index dd4e024..b566324 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -1779,6 +1779,15 @@ publishing directory.
Return output file name."
(org-publish-org-to 'texinfo filename ".texi" plist pub-dir))
+;;;###autoload
+(defun org-texinfo-convert-region-to-texinfo ()
+ "Assume the current region has org-mode syntax, and convert it to Texinfo.
+This can be used in any buffer. For example, you can write an
+itemized list in org-mode syntax in an Texinfo buffer and use
+this command to convert it."
+ (interactive)
+ (org-export-replace-region-by 'texinfo))
+
(defun org-texinfo-compile (file)
"Compile a texinfo file.
diff --git a/lisp/ox.el b/lisp/ox.el
index e2c1b5b..3618f83 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3057,6 +3057,18 @@ Return code as a string."
(org-export-as backend nil nil body-only ext-plist)))
;;;###autoload
+(defun org-export-replace-region-by (backend)
+ "Replace the active region by its export to BACKEND."
+ (if (not (org-region-active-p))
+ (user-error "No active region to replace")
+ (let* ((beg (region-beginning))
+ (end (region-end))
+ (str (buffer-substring beg end)) rpl)
+ (setq rpl (org-export-string-as str backend t))
+ (delete-region beg end)
+ (insert rpl))))
+
+;;;###autoload
(defun org-export-insert-default-template (&optional backend subtreep)
"Insert all export keywords with default values at beginning of line.