summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-11-14 13:41:27 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2012-11-14 13:43:11 (GMT)
commit72a27c3b3f29414a73da17842c325c6f21f77f10 (patch)
tree927538a90db937f8286da2dfd4d52fe6dadce9c7
parent3d56f5639936b38efd2f7a8979850505dffc7aaa (diff)
downloadorg-mode-72a27c3b3f29414a73da17842c325c6f21f77f10.zip
org-mode-72a27c3b3f29414a73da17842c325c6f21f77f10.tar.gz
org-export: Make backend registration more stable wrt Org reload
* contrib/lisp/org-export.el (org-export-define-backend, org-export-define-derived-backend): Modify backend properties if backend is already registered. (org-export-registered-backends): Use defvar instead of defconst so a reload doesn't reset it.
-rw-r--r--contrib/lisp/org-export.el43
1 files changed, 21 insertions, 22 deletions
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el
index 19e79c0..8641ba7 100644
--- a/contrib/lisp/org-export.el
+++ b/contrib/lisp/org-export.el
@@ -251,7 +251,7 @@ whose extension is either \"png\", \"jpeg\", \"jpg\", \"gif\",
See `org-export-inline-image-p' for more information about
rules.")
-(defconst org-export-registered-backends nil
+(defvar org-export-registered-backends nil
"List of backends currently available in the exporter.
A backend is stored as a list where CAR is its name, as a symbol,
@@ -840,7 +840,7 @@ keywords are understood:
structure of the values."
(declare (debug (&define name sexp [&rest [keywordp sexp]] defbody))
(indent 1))
- (let (export-block filters menu-entry options)
+ (let (export-block filters menu-entry options contents)
(while (keywordp (car body))
(case (pop body)
(:export-block (let ((names (pop body)))
@@ -851,15 +851,15 @@ keywords are understood:
(:menu-entry (setq menu-entry (pop body)))
(:options-alist (setq options (pop body)))
(t (pop body))))
+ (setq contents (append (list :translate-alist translators)
+ (and filters (list :filters-alist filters))
+ (and options (list :options-alist options))
+ (and menu-entry (list :menu-entry menu-entry))))
`(progn
;; Register back-end.
- (add-to-list
- 'org-export-registered-backends
- ',(cons backend
- (append (list :translate-alist translators)
- (and filters (list :filters-alist filters))
- (and options (list :options-alist options))
- (and menu-entry (list :menu-entry menu-entry)))))
+ (let ((registeredp (assq ',backend org-export-registered-backends)))
+ (if registeredp (setcdr registeredp ',contents)
+ (push (cons ',backend ',contents) org-export-registered-backends)))
;; Tell parser to not parse EXPORT-BLOCK blocks.
,(when export-block
`(mapc
@@ -925,7 +925,7 @@ The back-end could then be called with, for example:
\(org-export-to-buffer 'my-latex \"*Test my-latex*\")"
(declare (debug (&define name sexp [&rest [keywordp sexp]] def-body))
(indent 2))
- (let (export-block filters menu-entry options sub-menu-entry translators)
+ (let (export-block filters menu-entry options translators contents)
(while (keywordp (car body))
(case (pop body)
(:export-block (let ((names (pop body)))
@@ -935,22 +935,21 @@ The back-end could then be called with, for example:
(:filters-alist (setq filters (pop body)))
(:menu-entry (setq menu-entry (pop body)))
(:options-alist (setq options (pop body)))
- (:sub-menu-entry (setq sub-menu-entry (pop body)))
(:translate-alist (setq translators (pop body)))
(t (pop body))))
+ (setq contents (append
+ (let ((p-table (org-export-backend-translate-table parent)))
+ (list :translate-alist (append translators p-table)))
+ (let ((p-filters (org-export-backend-filters parent)))
+ (list :filters-alist (append filters p-filters)))
+ (let ((p-options (org-export-backend-options parent)))
+ (list :options-alist (append options p-options)))
+ (and menu-entry (list :menu-entry menu-entry))))
`(progn
;; Register back-end.
- (add-to-list
- 'org-export-registered-backends
- ',(cons child
- (append
- (let ((p-table (org-export-backend-translate-table parent)))
- (list :translate-alist (append translators p-table)))
- (let ((p-filters (org-export-backend-filters parent)))
- (list :filters-alist (append filters p-filters)))
- (let ((p-options (org-export-backend-options parent)))
- (list :options-alist (append options p-options)))
- (and menu-entry (list :menu-entry menu-entry)))))
+ (let ((registeredp (assq ',child org-export-registered-backends)))
+ (if registeredp (setcdr registeredp ',contents)
+ (push (cons ',child ',contents) org-export-registered-backends)))
;; Tell parser to not parse EXPORT-BLOCK blocks.
,(when export-block
`(mapc