* noninteractive use of org-export
@ 2014-04-16 14:14 Julien Cubizolles
2014-04-16 15:06 ` Thorsten Jolitz
2014-04-17 7:39 ` Bastien
0 siblings, 2 replies; 9+ messages in thread
From: Julien Cubizolles @ 2014-04-16 14:14 UTC (permalink / raw)
To: emacs-orgmode
How can I use org-beamer-export-to-pdf for example for an org file that
the current buffer isn't visiting?
My setup is the following : I have two org files cours-beamer.org and
cours-notes.org each containing different +LATEX_CLASS and
+LATEX_CLASS_OPTIONS choices and the same +#INCLUDE "cours.org"
file. I'd like to be able to run the export to beamer-pdf for both
cours-beamer.org and cours-notes.org from cours.org, or even from a bash
script but the documentation for org-beamer-export-to-pdf doesn't show
how.
Julien.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-16 14:14 noninteractive use of org-export Julien Cubizolles
@ 2014-04-16 15:06 ` Thorsten Jolitz
2014-04-17 7:39 ` Bastien
1 sibling, 0 replies; 9+ messages in thread
From: Thorsten Jolitz @ 2014-04-16 15:06 UTC (permalink / raw)
To: emacs-orgmode
Julien Cubizolles <j.cubizolles@free.fr> writes:
> How can I use org-beamer-export-to-pdf for example for an org file that
> the current buffer isn't visiting?
>
> My setup is the following : I have two org files cours-beamer.org and
> cours-notes.org each containing different +LATEX_CLASS and
> +LATEX_CLASS_OPTIONS choices and the same +#INCLUDE "cours.org"
> file. I'd like to be able to run the export to beamer-pdf for both
> cours-beamer.org and cours-notes.org from cours.org, or even from a bash
> script but the documentation for org-beamer-export-to-pdf doesn't show
> how.
This is untested! But maybe ...
#+begin_src emacs-lisp
(defvar my-beamer-files '("/path/to/file1" "/path/to/file2"))
(defun my-beamer-exp-fun ()
(interactive)
(when (consp my-beamer-files)
(mapc
(lambda (--file)
(with-current-buffer (find-file --file)
(org-mode)
(org-beamer-export-to-pdf)
(kill-buffer)))
my-beamer-files)))
#+end_src
#+results:
: my-beamer-exp-fun
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-16 14:14 noninteractive use of org-export Julien Cubizolles
2014-04-16 15:06 ` Thorsten Jolitz
@ 2014-04-17 7:39 ` Bastien
2014-04-17 9:33 ` Julien Cubizolles
1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2014-04-17 7:39 UTC (permalink / raw)
To: Julien Cubizolles; +Cc: emacs-orgmode
Hi Julien,
Julien Cubizolles <j.cubizolles@free.fr> writes:
> How can I use org-beamer-export-to-pdf for example for an org file that
> the current buffer isn't visiting?
>
> My setup is the following : I have two org files cours-beamer.org and
> cours-notes.org each containing different +LATEX_CLASS and
> +LATEX_CLASS_OPTIONS choices and the same +#INCLUDE "cours.org"
> file. I'd like to be able to run the export to beamer-pdf for both
> cours-beamer.org and cours-notes.org from cours.org, or even from a bash
> script but the documentation for org-beamer-export-to-pdf doesn't show
> how.
You need to setup a publishing project to export several files at
once.
HTH,
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-17 7:39 ` Bastien
@ 2014-04-17 9:33 ` Julien Cubizolles
2014-04-17 9:44 ` Bastien
0 siblings, 1 reply; 9+ messages in thread
From: Julien Cubizolles @ 2014-04-17 9:33 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
Bastien <bzg@gnu.org> writes:
> Hi Julien,
>
> Julien Cubizolles <j.cubizolles@free.fr> writes:
>
>> How can I use org-beamer-export-to-pdf for example for an org file that
>> the current buffer isn't visiting?
>>
>> My setup is the following : I have two org files cours-beamer.org and
>> cours-notes.org each containing different +LATEX_CLASS and
>> +LATEX_CLASS_OPTIONS choices and the same +#INCLUDE "cours.org"
>> file. I'd like to be able to run the export to beamer-pdf for both
>> cours-beamer.org and cours-notes.org from cours.org, or even from a bash
>> script but the documentation for org-beamer-export-to-pdf doesn't show
>> how.
>
> You need to setup a publishing project to export several files at
> once.
Thanks that seems to be exactly what I need. However, I'm not sure I'm
doing everything right:
Here is what I've tried so far
(setq org-publish-project-alist
'(("cours"
:base-directory "~/tmp/test_org"
:publishing-directory "~/tmp/test_org"
:publishing-function org-beamer-publish-to-pdf
:include ("1er-principe-beamer.org" "1er-principe-notes.org"))))
Something must be wrong with the :include syntax since every org file in
the base-directory is exported when I run C-c C-e P x.
Also, is it possible to specify export options like LATEX_CLASS_OPTIONS
from org-publish-project-alist ?
Julien.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-17 9:33 ` Julien Cubizolles
@ 2014-04-17 9:44 ` Bastien
2014-04-17 10:19 ` Julien Cubizolles
0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2014-04-17 9:44 UTC (permalink / raw)
To: Julien Cubizolles; +Cc: emacs-orgmode
Hi Julien,
Julien Cubizolles <j.cubizolles@free.fr> writes:
> Something must be wrong with the :include syntax since every org file in
> the base-directory is exported when I run C-c C-e P x.
Add :exclude ".*" on top of your include.
>
> Also, is it possible to specify export options like LATEX_CLASS_OPTIONS
> from org-publish-project-alist ?
Yes, use :latex-class-options in the publishing project.
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-17 9:44 ` Bastien
@ 2014-04-17 10:19 ` Julien Cubizolles
2014-04-17 10:38 ` Bastien
0 siblings, 1 reply; 9+ messages in thread
From: Julien Cubizolles @ 2014-04-17 10:19 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
Bastien <bzg@gnu.org> writes:
> Hi Julien,
>
> Julien Cubizolles <j.cubizolles@free.fr> writes:
>
>> Something must be wrong with the :include syntax since every org file in
>> the base-directory is exported when I run C-c C-e P x.
>
> Add :exclude ".*" on top of your include.
>>
>> Also, is it possible to specify export options like LATEX_CLASS_OPTIONS
>> from org-publish-project-alist ?
>
> Yes, use :latex-class-options in the publishing project.
Everything is working fine, thanks a lot. And it gave me another idea:
I'm actually exporting the same org file to pdf with different class
options (basically beamer and [handouts]beamer). It seems I could use
the :components property to export twice with different
:latex-class-options properties but I need to change name of the pdf
file produced so that cours.org produces cours-beamer.pdf and
cours-notes.pdf. Can this be achieved, maybe with :completion-function?
Julien.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-17 10:19 ` Julien Cubizolles
@ 2014-04-17 10:38 ` Bastien
2014-04-17 13:09 ` Julien Cubizolles
0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2014-04-17 10:38 UTC (permalink / raw)
To: Julien Cubizolles; +Cc: emacs-orgmode
Julien Cubizolles <j.cubizolles@free.fr> writes:
> Can this be achieved, maybe with :completion-function?
Maybe, but I never tried. Let us know if you can get it work!
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-17 10:38 ` Bastien
@ 2014-04-17 13:09 ` Julien Cubizolles
2014-04-17 13:40 ` Bastien
0 siblings, 1 reply; 9+ messages in thread
From: Julien Cubizolles @ 2014-04-17 13:09 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode
Bastien <bzg@gnu.org> writes:
> Julien Cubizolles <j.cubizolles@free.fr> writes:
>
>> Can this be achieved, maybe with :completion-function?
>
> Maybe, but I never tried. Let us know if you can get it work!
It works! I'm the first surprised here. I defined the following
functions to manipulate the filenames. I suspect my code is clumsy and
error prone but it works in the cases tested so far.
--8<---------------cut here---------------start------------->8---
(defun remove-org-suffix (name)
"Remove the .org from a file name"
(if (string-match "\\(.*\\)\\.org" name)
(substring name (match-beginning 1) (match-end 1))
name))
(defun jc-org-publish-rename-pdf (suffix)
"Rename file.pdf to file-beamer.pdf when buffer is visiting file.org"
(let* ((file-base-name (remove-org-suffix (buffer-file-name)))
(file-pdf-name (concat file-base-name ".pdf"))
(file-beamer-pdf-name (concat file-base-name "-" suffix ".pdf")))
(if (file-exists-p file-pdf-name)
(rename-file file-pdf-name file-beamer-pdf-name 1))
)
)
(defun jc-org-publish-rename-notes-pdf ()
"Rename file.pdf to file-notes.pdf when buffer is visiting file.org"
(jc-org-publish-rename-pdf '"notes"))
(defun jc-org-publish-rename-beamer-pdf ()
"Rename file.pdf to file-beamer.pdf when buffer is visiting file.org"
(jc-org-publish-rename-pdf '"beamer"))
--8<---------------cut here---------------end--------------->8---
Then this block in the beginning of a "master" .org file takes care of :
* calling the beamer export with different class/ class options
according to the project (beamer/notes) chosen
* renaming the pdf file according to the project (-beamer.pdf or
-notes.pdf)
* you can also use the "cours" project which publish both subprojects
--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp :tangle yes :exports none
(setq org-publish-project-alist
'(("beamer"
:base-directory "./"
:publishing-directory "./"
:publishing-function org-beamer-publish-to-pdf
:exclude ".*"
:latex-class "mpsi_beamer"
:include ("1er-principe.org")
:completion-function jc-org-publish-rename-beamer-pdf
)
("notes"
:base-directory "./"
:publishing-directory "./"
:publishing-function org-beamer-publish-to-pdf
:exclude ".*"
:latex-class "mpsi_beamer"
:include ("1er-principe.org")
:latex-class-options "[NotesCours]"
:completion-function jc-org-publish-rename-notes-pdf
)
("cours" :components ("beamer" "notes"))))
#+end_src
--8<---------------cut here---------------end--------------->8---
Thanks for guiding me.
Julien.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: noninteractive use of org-export
2014-04-17 13:09 ` Julien Cubizolles
@ 2014-04-17 13:40 ` Bastien
0 siblings, 0 replies; 9+ messages in thread
From: Bastien @ 2014-04-17 13:40 UTC (permalink / raw)
To: Julien Cubizolles; +Cc: emacs-orgmode
Julien Cubizolles <j.cubizolles@free.fr> writes:
> Thanks for guiding me.
No problem, glad it worked and thanks for the sharing the solution!
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-04-17 13:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-16 14:14 noninteractive use of org-export Julien Cubizolles
2014-04-16 15:06 ` Thorsten Jolitz
2014-04-17 7:39 ` Bastien
2014-04-17 9:33 ` Julien Cubizolles
2014-04-17 9:44 ` Bastien
2014-04-17 10:19 ` Julien Cubizolles
2014-04-17 10:38 ` Bastien
2014-04-17 13:09 ` Julien Cubizolles
2014-04-17 13:40 ` Bastien
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).