From mboxrd@z Thu Jan 1 00:00:00 1970 From: zwz Subject: Re: org-todo-keywords-1 detection in asyn export Date: Sat, 19 Apr 2014 21:47:39 +0800 Message-ID: <874n1pctxg.fsf@gmail.com> References: <87ppl1o9ok.fsf@gmail.com> <87sipc8me6.fsf@bzg.ath.cx> <87ha5scjdx.fsf@gmail.com> <87a9bj3e1a.fsf@gmail.com> <87d2ged8fx.fsf@gmail.com> <87y4z21mdw.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbVyl-0007BW-3X for emacs-orgmode@gnu.org; Sat, 19 Apr 2014 10:10:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WbVyd-0001cF-Ja for emacs-orgmode@gnu.org; Sat, 19 Apr 2014 10:10:51 -0400 Received: from plane.gmane.org ([80.91.229.3]:34509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbVyd-0001c7-Cf for emacs-orgmode@gnu.org; Sat, 19 Apr 2014 10:10:43 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WbVyc-0005PF-NH for emacs-orgmode@gnu.org; Sat, 19 Apr 2014 16:10:42 +0200 Received: from 218.108.113.238 ([218.108.113.238]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Apr 2014 16:10:42 +0200 Received: from zhangweize by 218.108.113.238 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Apr 2014 16:10:42 +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 Nicolas Goaziou writes: > zwz writes: > >> Can you give me some example code? > > I was thinking about something like this (untested): > > (let (template) > (defun ngz-set-template (new) > (setq template new)) > (defun ngz-latex-process (file) > (case template > (a (do-something-with file)) > (b (do-something-else-with file)) > (otherwise (do-default-with file))))) > > (defun ngz-latex-class-to-template (info backend) > (when (org-export-derived-backend-p backend 'latex) > (ngz-set-template > (let ((value (plist-get info :latex-class))) > (cond ((string= value "classA") 'a) > ((string= value "classB") 'b) > (t nil)))) > info)) > > (add-to-list 'org-export-filter-options-functions > 'ngz-latex-class-to-template) > > (setq org-latex-pdf-process #'ngz-latex-process) > > Obviously, you need to activate lexical binding. > >> I am not sure if I get you totally. > > I was talking about BIND keyword, not about your initial > implementation. Thank you, Nicolas. I used BIND before, but never like what your example code does. > >> Here is what I put in my org-export-async-init-file: >> (defun ox-xetex-setup () >> (if (member "XeTeX" org-todo-keywords-1) >> (setq org-latex-default-packages-alist >> (remove '("AUTO" "inputenc" t) >> org-latex-default-packages-alist) >> org-latex-pdf-process >> '("latexmk -xelatex -pdf -silent -f %f")))) >> >> (add-hook 'org-mode-hook (lambda () (ox-xetex-setup))) >> ;; instead of add-hook as above, you can just put >> ;; (ox-xetex-setup) >> ;; but again, it still calls pdflatex when export asynchronously >> > > [...] > >> When I export it asynchronously, org-export calls pdflatex rather than >> xelatex to generate pdf. > > I think the problem comes from `org-todo-keywords-1'. Its value is > probably not updated during export. Yes, I guess so. But it worked during *synchronous* export, even when I put #+TODO: XeTeX in a common option-template file, which is then included by #+SETUPFILE in many org files. > > > Regards,