New interactive export functions for 'e-latex back-end

* EXPERIMENTAL/org-e-latex.el (org-e-latex-export-to-latex,
  org-e-latex-export-to-pdf): New functions.
* contrib/lisp/org-export.el (org-export-dispatch): Make use of new
  functions.
This commit is contained in:
Nicolas Goaziou 2012-01-17 20:27:10 +01:00
parent 418f63c8b1
commit ecfb12de19
2 changed files with 80 additions and 18 deletions

View File

@ -1911,7 +1911,71 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;; Compilation
;;; Interactive functions
(defun org-e-latex-export-to-latex
(&optional subtreep visible-only body-only ext-plist pub-dir)
"Export current buffer to a LaTeX file.
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
When optional argument BODY-ONLY is non-nil, only write code
between \"\\begin{document}\" and \"\\end{document}\".
EXT-PLIST, when provided, is a property list with external
parameters overriding Org default settings, but still inferior to
file-local settings.
When optional argument PUB-DIR is set, use it as the publishing
directory.
Return output file's name."
(interactive)
(let ((outfile (org-export-output-file-name ".tex" subtreep pub-dir)))
(org-export-to-file
'e-latex outfile subtreep visible-only body-only ext-plist)))
(defun org-e-latex-export-to-pdf
(&optional subtreep visible-only body-only ext-plist pub-dir)
"Export current buffer to LaTeX then process through to PDF.
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
When optional argument BODY-ONLY is non-nil, only write code
between \"\\begin{document}\" and \"\\end{document}\".
EXT-PLIST, when provided, is a property list with external
parameters overriding Org default settings, but still inferior to
file-local settings.
When optional argument PUB-DIR is set, use it as the publishing
directory.
Return PDF file's name."
(interactive)
(org-e-latex-compile
(org-e-latex-export-to-latex
subtreep visible-only body-only ext-plist pub-dir)))
(defun org-e-latex-compile (texfile)
"Compile a TeX file.

View File

@ -2797,23 +2797,21 @@ Return an error if key pressed has no associated command."
;; depending on user's key pressed.
(case (if (< raw-key 27) (+ raw-key 96) raw-key)
;; Export with `e-latex' back-end.
(?L (let ((outbuf (org-export-to-buffer
'e-latex "*Org E-latex Export*"
(memq 'subtree scope)
(memq 'visible scope)
(memq 'body scope))))
(?L
(let ((outbuf
(org-export-to-buffer
'e-latex "*Org E-LaTeX Export*"
(memq 'subtree scope) (memq 'visible scope) (memq 'body scope))))
(with-current-buffer outbuf (latex-mode))
(when org-export-show-temporary-export-buffer
(switch-to-buffer-other-window outbuf))))
((?l ?p ?d)
(org-export-to-file
'e-latex
(cond ((eq raw-key ?p) #'org-e-latex-compile)
((eq raw-key ?d)
(lambda (file) (org-open-file (org-e-latex-compile file)))))
(memq 'subtree scope)
(memq 'visible scope)
(memq 'body scope)))
(?l (org-e-latex-export-to-latex
(memq 'subtree scope) (memq 'visible scope) (memq 'body scope)))
(?p (org-e-latex-export-to-pdf
(memq 'subtree scope) (memq 'visible scope) (memq 'body scope)))
(?d (org-open-file
(org-e-latex-export-to-pdf
(memq 'subtree scope) (memq 'visible scope) (memq 'body scope))))
;; Undefined command.
(t (error "No command associated with key %s"
(char-to-string raw-key))))))