From: Julien Cubizolles <j.cubizolles@free.fr>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: noninteractive use of org-export
Date: Thu, 17 Apr 2014 15:09:43 +0200 [thread overview]
Message-ID: <87ha5sxfu0.fsf@free.fr> (raw)
In-Reply-To: <87wqeo2qcs.fsf@bzg.ath.cx> (Bastien's message of "Thu, 17 Apr 2014 12:38:11 +0200")
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.
next prev parent reply other threads:[~2014-04-17 13:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2014-04-17 13:40 ` Bastien
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=87ha5sxfu0.fsf@free.fr \
--to=j.cubizolles@free.fr \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/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).