emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: zwz <zhangweize@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-todo-keywords-1 detection in asyn export
Date: Fri, 18 Apr 2014 21:13:47 +0200	[thread overview]
Message-ID: <87y4z21mdw.fsf@gmail.com> (raw)
In-Reply-To: <87d2ged8fx.fsf@gmail.com> (zwz's message of "Fri, 18 Apr 2014 22:21:54 +0800")

zwz <zhangweize@gmail.com> writes:

> Can you give me some example code?

I was thinking about something like this (untested):

--8<---------------cut here---------------start------------->8---
(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)
--8<---------------cut here---------------end--------------->8---

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.

> 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.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2014-04-18 19:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01  6:17 org-todo-keywords-1 detection in asyn export zwz
2014-04-17  7:07 ` Bastien
2014-04-17 10:58   ` zwz
2014-04-17 20:18     ` Nicolas Goaziou
2014-04-18 14:21       ` zwz
2014-04-18 19:13         ` Nicolas Goaziou [this message]
2014-04-19 13:47           ` zwz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y4z21mdw.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=zhangweize@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).