Function: org-export-define-derived-backend

org-export-define-derived-backend is a byte-compiled function defined in ox.el.gz.

Signature

(org-export-define-derived-backend CHILD PARENT &rest BODY)

Documentation

Create a new backend as a variant of an existing one.

CHILD is the name of the derived backend. PARENT is the name of the parent backend.

BODY can start with pre-defined keyword arguments. The following keywords are understood:

  :filters-alist

    Alist of filters that will overwrite or complete filters
    defined in PARENT backend. See org-export-filters-alist
    for a list of allowed filters.

  :menu-entry

    Menu entry for the export dispatcher. See
    org-export-define-backend for more information about the
    expected value.

  :options-alist

    Alist of backend specific properties that will overwrite or
    complete those defined in PARENT backend. Refer to
    org-export-options-alist for more information about
    structure of the values.

  :translate-alist

    Alist of element and object types and transcoders that will
    overwrite or complete transcode table from PARENT backend.
    Refer to org-export-define-backend for detailed information
    about transcoders.

As an example, here is how one could define "my-latex" backend as a variant of latex backend with a custom template function:

  (org-export-define-derived-backend 'my-latex 'latex
     :translate-alist '((template . my-latex-template-fun)))

The backend could then be called with, for example:

  (org-export-to-buffer 'my-latex "*Test my-latex*")

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export-define-derived-backend (child parent &rest body)
  "Create a new backend as a variant of an existing one.

CHILD is the name of the derived backend.  PARENT is the name of
the parent backend.

BODY can start with pre-defined keyword arguments.  The following
keywords are understood:

  :filters-alist

    Alist of filters that will overwrite or complete filters
    defined in PARENT backend.  See `org-export-filters-alist'
    for a list of allowed filters.

  :menu-entry

    Menu entry for the export dispatcher.  See
    `org-export-define-backend' for more information about the
    expected value.

  :options-alist

    Alist of backend specific properties that will overwrite or
    complete those defined in PARENT backend.  Refer to
    `org-export-options-alist' for more information about
    structure of the values.

  :translate-alist

    Alist of element and object types and transcoders that will
    overwrite or complete transcode table from PARENT backend.
    Refer to `org-export-define-backend' for detailed information
    about transcoders.

As an example, here is how one could define \"my-latex\" backend
as a variant of `latex' backend with a custom template function:

  (org-export-define-derived-backend \\='my-latex \\='latex
     :translate-alist \\='((template . my-latex-template-fun)))

The backend could then be called with, for example:

  (org-export-to-buffer \\='my-latex \"*Test my-latex*\")"
  (declare (indent 2))
  (let (filters menu-entry options transcoders)
    (while (keywordp (car body))
      (let ((keyword (pop body)))
	(pcase keyword
	  (:filters-alist (setq filters (pop body)))
	  (:menu-entry (setq menu-entry (pop body)))
	  (:options-alist (setq options (pop body)))
	  (:translate-alist (setq transcoders (pop body)))
	  (_ (error "Unknown keyword: %s" keyword)))))
    (org-export-register-backend
     (org-export-create-backend :name child
				:parent parent
				:transcoders transcoders
				:options options
				:filters filters
				:menu menu-entry))))