From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: define a new export backend Date: Thu, 31 Jul 2014 00:11:56 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e011763aff3084604ff77fc7f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCkWs-00015C-Sz for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 03:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCkWr-0002V0-KU for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 03:11:58 -0400 Received: from mail-vc0-x231.google.com ([2607:f8b0:400c:c03::231]:33211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCkWr-0002Un-Fd for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 03:11:57 -0400 Received: by mail-vc0-f177.google.com with SMTP id hy4so3513396vcb.36 for ; Thu, 31 Jul 2014 00:11:56 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" --089e011763aff3084604ff77fc7f Content-Type: text/plain; charset=UTF-8 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 " %s " contents)) --089e011763aff3084604ff77fc7f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,=C2=A0
=C2=A0 =C2=A0 I try to define a new export b= ackend in the new export framework. My export backend should behaves like t= he html except that it transcodes *bold* differently. =C2=A0I try to follow= ing the Worg tutorial=C2=A0http://orgmode.org/worg/dev/org-export-= reference.html=C2=A0, ox-html.el and use org-export-define-derived-back= end. I can see the new backend showing up in the export menu(C-c C-e), but = my transcoder for bold is not used. =C2=A0Any help or reference pointer is = appreciated.=C2=A0

Shiyuan=C2=A0


-----------= --------------
(org-export-define-derived-backend 'my-html-en= lish 'html
=C2=A0 :traslate-alist '((bold . my-org-html-e= nglish-bold))
=C2=A0 =C2=A0:menu-entry
=C2=A0 '(?E "Export to HTM= L-ENGLISH"
=C2=A0 =C2=A0 =C2=A0 =C2=A0((?H "As HTML buf= fer" my-org-html-english-export-as-html)
)))
------------------------------
(defun my-org-html-english-ex= port-as-html
=C2=A0 (&optional async subtreep visible-only bo= dy-only ext-plist)
=C2=A0"This is almost copied from org-htm= l-export-as-html except using my newly defined backend"
=C2=A0 (interactive)
=C2=A0 (org-export-to-buffer '= ;my-html-enlish "*Org HTML-ENG Export*"
=C2=A0 =C2=A0 a= sync subtreep visible-only body-only ext-plist
=C2=A0 =C2=A0 (lam= bda () (set-auto-mode t))))
-------------------
(defun my-org-html-engli= sh-bold (bold contents info)
=C2=A0 "Transcode BOLD from Org= to HTML. Intead of using ordinary bold, we use color to highlight the=C2= =A0
CONTENTS is the text with bold markup. =C2=A0INFO is a plist holding
contextual information."
=C2=A0 (format "<s= pan style=3D\"color: #a020f0\"> %s </span>"
=C2=A0=C2=A0contents)= )
--089e011763aff3084604ff77fc7f-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: define a new export backend Date: Thu, 31 Jul 2014 09:27:11 +0200 Message-ID: <87bns69eeo.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCklu-0005AC-NV for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 03:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCklp-0007n0-W9 for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 03:27:30 -0400 Received: from plane.gmane.org ([80.91.229.3]:59315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCklp-0007mr-Pi for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 03:27:25 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XCklp-0004ko-9G for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 09:27:25 +0200 Received: from g231110029.adsl.alicedsl.de ([92.231.110.29]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 31 Jul 2014 09:27:25 +0200 Received: from tjolitz by g231110029.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 31 Jul 2014 09:27:25 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Shiyuan 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Richard Subject: Re: define a new export backend Date: Thu, 31 Jul 2014 10:08:06 +0200 Message-ID: <877g2uymqh.fsf@geodiff-mac3.ulb.ac.be> References: <87bns69eeo.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XClNN-0002vw-RJ for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 04:06:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XClNG-0002Gz-Bc for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 04:06:13 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:39416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XClNG-0002Gs-5g for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 04:06:06 -0400 In-Reply-To: <87bns69eeo.fsf@gmail.com> (Thorsten Jolitz's message of "Thu, 31 Jul 2014 09:27:11 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: emacs-orgmode@gnu.org, Nicolas Goaziou Thorsten Jolitz writes: > Shiyuan 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. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: define a new export backend Date: Thu, 31 Jul 2014 10:39:46 +0200 Message-ID: <87k36tkjl9.fsf@nicolasgoaziou.fr> References: <87bns69eeo.fsf@gmail.com> <877g2uymqh.fsf@geodiff-mac3.ulb.ac.be> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCltJ-0005UY-5X for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 04:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCltB-0005G1-Tf for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 04:39:13 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:60276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCltB-0005Fs-N1 for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 04:39:05 -0400 In-Reply-To: <877g2uymqh.fsf@geodiff-mac3.ulb.ac.be> (Nicolas Richard's message of "Thu, 31 Jul 2014 10:08:06 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Richard Cc: emacs-orgmode@gnu.org, Thorsten Jolitz Hello, Nicolas Richard 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Richard Subject: Re: define a new export backend Date: Thu, 31 Jul 2014 11:17:08 +0200 Message-ID: <87tx5xyjjf.fsf@geodiff-mac3.ulb.ac.be> References: <87bns69eeo.fsf@gmail.com> <877g2uymqh.fsf@geodiff-mac3.ulb.ac.be> <87k36tkjl9.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCmSA-0001V5-By for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 05:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCmS4-0006tP-Ha for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 05:15:14 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:53240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCmS4-0006so-Bp for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 05:15:08 -0400 In-Reply-To: <87k36tkjl9.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Thu, 31 Jul 2014 10:39:46 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Richard Cc: emacs-orgmode@gnu.org, Thorsten Jolitz --=-=-= Content-Type: text/plain Nicolas Goaziou 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Signal-an-error-if-keyword-is-unknown-while-defining.patch >From 117623cec251cd036b601e2481643296cc4e2c37 Mon Sep 17 00:00:00 2001 From: Nicolas Richard 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 --=-=-= Content-Type: text/plain -- Nico. --=-=-=-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: define a new export backend Date: Thu, 31 Jul 2014 13:41:12 +0200 Message-ID: <87wqatiwmf.fsf@nicolasgoaziou.fr> References: <87bns69eeo.fsf@gmail.com> <877g2uymqh.fsf@geodiff-mac3.ulb.ac.be> <87k36tkjl9.fsf@nicolasgoaziou.fr> <87tx5xyjjf.fsf@geodiff-mac3.ulb.ac.be> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCois-0002ad-V7 for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 07:40:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCoil-0004W3-Nh for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 07:40:38 -0400 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:45992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCoil-0004Vx-Hr for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 07:40:31 -0400 In-Reply-To: <87tx5xyjjf.fsf@geodiff-mac3.ulb.ac.be> (Nicolas Richard's message of "Thu, 31 Jul 2014 11:17:08 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Richard Cc: Thorsten Jolitz , emacs-orgmode@gnu.org Hello, Nicolas Richard 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Re: define a new export backend Date: Thu, 31 Jul 2014 15:04:34 -0700 Message-ID: References: <87bns69eeo.fsf@gmail.com> <877g2uymqh.fsf@geodiff-mac3.ulb.ac.be> <87k36tkjl9.fsf@nicolasgoaziou.fr> <87tx5xyjjf.fsf@geodiff-mac3.ulb.ac.be> <87wqatiwmf.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113626483dbeb604ff8475fb Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCySi-0002yw-Nm for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 18:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCySh-0003vE-Rh for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 18:04:36 -0400 Received: from mail-vc0-x236.google.com ([2607:f8b0:400c:c03::236]:52717) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCySh-0003v3-MP for emacs-orgmode@gnu.org; Thu, 31 Jul 2014 18:04:35 -0400 Received: by mail-vc0-f182.google.com with SMTP id hy4so5478572vcb.27 for ; Thu, 31 Jul 2014 15:04:34 -0700 (PDT) In-Reply-To: <87wqatiwmf.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Richard , "emacs-orgmode@gnu.org" , Thorsten Jolitz --001a113626483dbeb604ff8475fb Content-Type: text/plain; charset=UTF-8 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 wrote: > Hello, > > Nicolas Richard 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 > > --001a113626483dbeb604ff8475fb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Oops, =C2=A0I've asked the dumpest question ever in th= e mailing list :) That's what happens when working late.=C2=A0

=
Thanks for reply.=C2=A0

On Thu, Jul 31, 2014 at 4:41 AM, Nicolas Goaziou <mail@nicolasgoaziou= .fr> wrote:
Hello,

Nicolas Richard <theon= ewiththeevillook@yahoo.fr> writes:

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

Applied. Thank you.


Regards,

--
Nicolas Goaziou


--001a113626483dbeb604ff8475fb--