org-e-publish: Move publishing functions into back-end libraries

* contrib/lisp/org-e-ascii.el (org-e-ascii-publish-to-ascii,
  org-e-ascii-publish-to-latin1, org-e-ascii-publish-to-utf8): New
  functions.
* contrib/lisp/org-e-html.el (org-e-html-publish-to-html): New
  function.
* contrib/lisp/org-e-latex.el (org-e-latex-publish-to-latex,
  org-e-latex-publish-to-pdf): New functions.
* contrib/lisp/org-e-publish.el (org-e-publish-org-to-latex,
  org-e-publish-org-to-pdf, org-e-publish-org-to-ascii,
  org-e-publish-org-to-latin1, org-e-publish-org-to-utf8,
  org-e-publish-org-to-html): Remove functions.

Each back-end can define its own publishing functions.  This patch
avoids to clutter org-e-publish.el.
This commit is contained in:
Nicolas Goaziou 2012-10-08 14:20:56 +02:00
parent 19a28c5528
commit 9109dc13ea
4 changed files with 81 additions and 86 deletions

View File

@ -37,6 +37,7 @@
(eval-when-compile (require 'cl))
(require 'org-export)
(require 'org-e-publish)
(declare-function aa2u "ext:ascii-art-to-unicode" ())
@ -1794,7 +1795,7 @@ This function only applies to `e-ascii' back-end. See
;;; Interactive function
;;; End-user functions
;;;###autoload
(defun org-e-ascii-export-as-ascii
@ -1864,6 +1865,42 @@ Return output file's name."
(org-export-to-file
'e-ascii outfile subtreep visible-only body-only ext-plist)))
;;;###autoload
(defun org-e-ascii-publish-to-ascii (plist filename pub-dir)
"Publish an Org file to ASCII.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to
'e-ascii filename ".txt" `(:ascii-charset ascii ,@plist) pub-dir))
;;;###autoload
(defun org-e-ascii-publish-to-latin1 (plist filename pub-dir)
"Publish an Org file to Latin-1.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to
'e-ascii filename ".txt" `(:ascii-charset latin1 ,@plist) pub-dir))
;;;###autoload
(defun org-e-ascii-publish-to-utf8 (plist filename pub-dir)
"Publish an org file to UTF-8.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to
'e-ascii filename ".txt" `(:ascii-charset utf-8 ,@plist) pub-dir))
(provide 'org-e-ascii)
;;; org-e-ascii.el ends here

View File

@ -36,6 +36,7 @@
;;; Dependencies
(require 'org-export)
(require 'org-e-publish)
(require 'format-spec)
(eval-when-compile (require 'cl) (require 'table))
@ -2806,7 +2807,7 @@ contextual information."
(buffer-substring-no-properties (point-min) (point-max)))))
;;; Interactive functions
;;; End-user functions
;;;###autoload
(defun org-e-html-export-as-html
@ -2880,6 +2881,17 @@ Return output file's name."
(org-export-to-file
'e-html file subtreep visible-only body-only ext-plist)))
;;;###autoload
(defun org-e-html-publish-to-html (plist filename pub-dir)
"Publish an org file to HTML.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to 'e-html filename ".html" plist pub-dir))
;;; FIXME

View File

@ -37,6 +37,7 @@
(eval-when-compile (require 'cl))
(require 'org-export)
(require 'org-e-publish)
(defvar org-export-latex-default-packages-alist)
(defvar org-export-latex-packages-alist)
@ -2556,7 +2557,7 @@ contextual information."
;;; Interactive functions
;;; End-user functions
;;;###autoload
(defun org-e-latex-export-as-latex
@ -2734,6 +2735,33 @@ none."
(setq errors (concat errors " " (cdr latex-error)))))
(and (org-string-nw-p errors) (org-trim errors)))))))
;;;###autoload
(defun org-e-latex-publish-to-latex (plist filename pub-dir)
"Publish an Org file to LaTeX.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to 'e-latex filename ".tex" plist pub-dir))
;;;###autoload
(defun org-e-latex-publish-to-pdf (plist filename pub-dir)
"Publish an Org file to PDF (via LaTeX).
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
;; Unlike to `org-e-latex-publish-to-latex', PDF file is generated
;; in working directory and then moved to publishing directory.
(org-e-publish-attachment
plist
(org-e-latex-compile (org-e-publish-org-to 'e-latex filename ".tex" plist))
pub-dir))
(provide 'org-e-latex)
;;; org-e-latex.el ends here

View File

@ -538,7 +538,7 @@ matching filenames."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Pluggable publishing back-end functions
;;; Tools for publishing functions in back-ends
(defun org-e-publish-org-to (backend filename extension plist &optional pub-dir)
"Publish an Org file to a specified back-end.
@ -574,88 +574,6 @@ Return output file name."
(unless visitingp (kill-buffer work-buffer)))))
(defvar project-plist)
(defun org-e-publish-org-to-latex (plist filename pub-dir)
"Publish an Org file to LaTeX.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(require 'org-e-latex nil t)
(org-e-publish-org-to 'e-latex filename ".tex" plist pub-dir))
(defun org-e-publish-org-to-pdf (plist filename pub-dir)
"Publish an Org file to PDF \(via LaTeX).
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(require 'org-e-latex nil t)
;; Unlike to `org-e-publish-org-to-latex', PDF file is generated in
;; working directory and then moved to publishing directory.
(org-e-publish-attachment
plist
(org-e-latex-compile (org-e-publish-org-to 'e-latex filename ".tex" plist))
pub-dir))
(defun org-e-publish-org-to-html (plist filename pub-dir)
"Publish an org file to HTML.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(require 'org-e-html nil t)
(org-e-publish-org-to 'e-html filename ".html" plist pub-dir))
;; TODO: Not implemented yet.
;; (defun org-e-publish-org-to-org (plist filename pub-dir)
;; "Publish an org file to HTML.
;;
;; FILENAME is the filename of the Org file to be published. PLIST
;; is the property list for the given project. PUB-DIR is the
;; publishing directory.
;;
;; Return output file name."
;; (org-e-publish-org-to "org" plist filename pub-dir))
(defun org-e-publish-org-to-ascii (plist filename pub-dir)
"Publish an Org file to ASCII.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(require 'org-e-ascii nil t)
(org-e-publish-org-to
'e-ascii filename ".txt" `(:ascii-charset ascii ,@plist) pub-dir))
(defun org-e-publish-org-to-latin1 (plist filename pub-dir)
"Publish an Org file to Latin-1.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to
'e-ascii filename ".txt" `(:ascii-charset latin1 ,@plist) pub-dir))
(defun org-e-publish-org-to-utf8 (plist filename pub-dir)
"Publish an org file to UTF-8.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to
'e-ascii filename ".txt" `(:ascii-charset utf-8 ,@plist) pub-dir))
(defun org-e-publish-attachment (plist filename pub-dir)
"Publish a file with no transformation of any kind.