[O] define a new export backend

2014-07-31 Thread Shiyuan
Hi,
I try to define a new export backend in the new export framework. My
export backend should behaves like the html except that it transcodes
*bold* differently.  I try to following the Worg tutorial
http://orgmode.org/worg/dev/org-export-reference.html , ox-html.el and use
org-export-define-derived-backend. I can see the new backend showing up in
the export menu(C-c C-e), but my transcoder for bold is not used.  Any help
or reference pointer is appreciated.

Shiyuan


-
(org-export-define-derived-backend 'my-html-enlish 'html
  :traslate-alist '((bold . my-org-html-english-bold))
   :menu-entry
  '(?E Export to HTML-ENGLISH
   ((?H As HTML buffer my-org-html-english-export-as-html)
)))
--
(defun my-org-html-english-export-as-html
  (optional async subtreep visible-only body-only ext-plist)
 This is almost copied from org-html-export-as-html except using my newly
defined backend
  (interactive)
  (org-export-to-buffer 'my-html-enlish *Org HTML-ENG Export*
async subtreep visible-only body-only ext-plist
(lambda () (set-auto-mode t
---
(defun my-org-html-english-bold (bold contents info)
  Transcode BOLD from Org to HTML. Intead of using ordinary bold, we use
color to highlight the
CONTENTS is the text with bold markup.  INFO is a plist holding
contextual information.
  (format span style=\color: #a020f0\ %s /span
  contents))


Re: [O] define a new export backend

2014-07-31 Thread Thorsten Jolitz
Shiyuan gshy2...@gmail.com writes:

 Hi, 
 I try to define a new export backend in the new export framework. My
 export backend should behaves like the html except that it transcodes
 *bold* differently. I try to following the Worg tutorial
 http://orgmode.org/worg/dev/org-export-reference.html , ox-html.el and
 use org-export-define-derived-backend. I can see the new backend
 showing up in the export menu(C-c C-e), but my transcoder for bold is
 not used. Any help or reference pointer is appreciated. 

 Shiyuan 

 -
 (org-export-define-derived-backend 'my-html-enlish 'html
 :traslate-alist '((bold . my-org-html-english-bold))


:translate-alist ?

-- 
cheers,
Thorsten




Re: [O] define a new export backend

2014-07-31 Thread Nicolas Richard
Thorsten Jolitz tjol...@gmail.com writes:
 Shiyuan gshy2...@gmail.com writes:
 (org-export-define-derived-backend 'my-html-enlish 'html
 :traslate-alist '((bold . my-org-html-english-bold))


 :translate-alist ?

Perhaps org-export-define-derived-backend could do a sanity check that
all keywords are known. use-package does that, and it has saved me
multiple times ! Nicolas, what am I overlooking ?

Modified   lisp/ox.el
diff --git a/lisp/ox.el b/lisp/ox.el
index 03bd8bb..e931723 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -1187,9 +1187,9 @@ The back-end could then be called with, for example:
 
   \(org-export-to-buffer 'my-latex \*Test my-latex*\)
   (declare (indent 2))
-  (let (blocks filters menu-entry options transcoders contents)
+  (let (blocks filters menu-entry options transcoders contents keyword)
 (while (keywordp (car body))
-  (case (pop body)
+  (case (setq keyword (pop body))
(:export-block (let ((names (pop body)))
 (setq blocks (if (consp names) (mapcar 'upcase names)
(list (upcase names))
@@ -1197,7 +1197,7 @@ The back-end could then be called with, for example:
(:menu-entry (setq menu-entry (pop body)))
 (:options-alist (setq options (pop body)))
 (:translate-alist (setq transcoders (pop body)))
-(t (pop body
+(t (error Unknown keyword in `org-export-define-derived-backend': %s 
keyword
 (org-export-register-backend
  (org-export-create-backend :name child
:parent parent

-- 
Nico.



Re: [O] define a new export backend

2014-07-31 Thread Nicolas Goaziou
Hello,

Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Perhaps org-export-define-derived-backend could do a sanity check that
 all keywords are known.

Good idea, as long as `org-export-define-backend' does the same.

 -  (let (blocks filters menu-entry options transcoders contents)
 +  (let (blocks filters menu-entry options transcoders contents keyword)

KEYWORD should be let-bound within the while loop.

  (while (keywordp (car body))
 -  (case (pop body)
 +  (case (setq keyword (pop body))


  (while (keywordp (car body))
(let ((keyword (pop body)))
  (case keyword
(...)
(t (error Unknown keyword: %s keyword)


Regards,

-- 
Nicolas Goaziou



Re: [O] define a new export backend

2014-07-31 Thread Nicolas Richard
Nicolas Goaziou m...@nicolasgoaziou.fr writes:
 Good idea, as long as `org-export-define-backend' does the same.

Oops, I forgot to remove the verbosity (initially I had wrote it as a
(warn ...)). Here's an updated patch.

From 117623cec251cd036b601e2481643296cc4e2c37 Mon Sep 17 00:00:00 2001
From: Nicolas Richard theonewiththeevill...@yahoo.fr
Date: Thu, 31 Jul 2014 10:48:54 +0200
Subject: [PATCH] Signal an error if keyword is unknown while defining backends

* lisp/ox.el (org-export-define-backend):
(org-export-define-derived-backend): Signal an error if keyword is unknown
---
 lisp/ox.el | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 03bd8bb..e2965c4 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -1118,14 +1118,15 @@ keywords are understood:
   (declare (indent 1))
   (let (blocks filters menu-entry options contents)
 (while (keywordp (car body))
-  (case (pop body)
-(:export-block (let ((names (pop body)))
-			 (setq blocks (if (consp names) (mapcar 'upcase names)
-	(list (upcase names))
-	(:filters-alist (setq filters (pop body)))
-	(:menu-entry (setq menu-entry (pop body)))
-(:options-alist (setq options (pop body)))
-(t (pop body
+  (let ((keyword (pop body)))
+	(case keyword
+	  (:export-block (let ((names (pop body)))
+			   (setq blocks (if (consp names) (mapcar 'upcase names)
+	  (list (upcase names))
+	  (:filters-alist (setq filters (pop body)))
+	  (:menu-entry (setq menu-entry (pop body)))
+	  (:options-alist (setq options (pop body)))
+	  (t (error Unknown keyword: %s keyword)
 (org-export-register-backend
  (org-export-create-backend :name backend
 :transcoders transcoders
@@ -1189,15 +1190,16 @@ The back-end could then be called with, for example:
   (declare (indent 2))
   (let (blocks filters menu-entry options transcoders contents)
 (while (keywordp (car body))
-  (case (pop body)
-	(:export-block (let ((names (pop body)))
-			 (setq blocks (if (consp names) (mapcar 'upcase names)
-	(list (upcase names))
-(: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)))
-(t (pop body
+  (let ((keyword (pop body)))
+	(case keyword
+	  (:export-block (let ((names (pop body)))
+			   (setq blocks (if (consp names) (mapcar 'upcase names)
+	  (list (upcase names))
+	  (: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)))
+	  (t (error Unknown keyword: %s keyword)
 (org-export-register-backend
  (org-export-create-backend :name child
 :parent parent
-- 
1.8.5.5


-- 
Nico.


Re: [O] define a new export backend

2014-07-31 Thread Nicolas Goaziou
Hello,

Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Oops, I forgot to remove the verbosity (initially I had wrote it as a
 (warn ...)). Here's an updated patch.

Applied. Thank you.


Regards,

-- 
Nicolas Goaziou



Re: [O] define a new export backend

2014-07-31 Thread Shiyuan
Oops,  I've asked the dumpest question ever in the mailing list :) That's
what happens when working late.

Thanks for reply.


On Thu, Jul 31, 2014 at 4:41 AM, Nicolas Goaziou m...@nicolasgoaziou.fr
wrote:

 Hello,

 Nicolas Richard theonewiththeevill...@yahoo.fr writes:

  Oops, I forgot to remove the verbosity (initially I had wrote it as a
  (warn ...)). Here's an updated patch.

 Applied. Thank you.


 Regards,

 --
 Nicolas Goaziou