Re: [O] noninteractive use of org-export

2014-04-17 Thread Bastien
Julien Cubizolles  writes:

> Thanks for guiding me.

No problem, glad it worked and thanks for the sharing the solution!

-- 
 Bastien



Re: [O] noninteractive use of org-export

2014-04-17 Thread Julien Cubizolles
Bastien  writes:

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



Re: [O] noninteractive use of org-export

2014-04-17 Thread Bastien
Julien Cubizolles  writes:

> Can this be achieved, maybe with :completion-function?

Maybe, but I never tried.  Let us know if you can get it work!

-- 
 Bastien



Re: [O] noninteractive use of org-export

2014-04-17 Thread Julien Cubizolles
Bastien  writes:

> Hi Julien,
>
> Julien Cubizolles  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.



Re: [O] noninteractive use of org-export

2014-04-17 Thread Bastien
Hi Julien,

Julien Cubizolles  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



Re: [O] noninteractive use of org-export

2014-04-17 Thread Julien Cubizolles
Bastien  writes:

> Hi Julien,
>
> Julien Cubizolles  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.



Re: [O] noninteractive use of org-export

2014-04-17 Thread Bastien
Hi Julien,

Julien Cubizolles  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



Re: [O] noninteractive use of org-export

2014-04-16 Thread Thorsten Jolitz
Julien Cubizolles  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




[O] noninteractive use of org-export

2014-04-16 Thread Julien Cubizolles
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.