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.
This commit is contained in:
Bastien Guerry 2013-04-06 19:09:38 +02:00
parent 133afe8915
commit 1e496cc8f9
5 changed files with 48 additions and 0 deletions

View File

@ -3193,6 +3193,15 @@ is non-nil."
(when org-export-show-temporary-export-buffer
(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)

View File

@ -2821,6 +2821,15 @@ is non-nil."
(when org-export-show-temporary-export-buffer
(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)

View File

@ -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)

View File

@ -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.

View File

@ -3056,6 +3056,18 @@ Return code as a string."
(org-mode)
(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.