[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] noninteractive use of org-export
From: |
Julien Cubizolles |
Subject: |
Re: [O] noninteractive use of org-export |
Date: |
Thu, 17 Apr 2014 15:09:43 +0200 |
User-agent: |
Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.4.50 (gnu/linux) |
Bastien <address@hidden> writes:
> Julien Cubizolles <address@hidden> 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.