From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Cubizolles Subject: Re: noninteractive use of org-export Date: Thu, 17 Apr 2014 15:09:43 +0200 Message-ID: <87ha5sxfu0.fsf@free.fr> References: <87y4z5xsxw.fsf@free.fr> <877g6o8kvu.fsf@bzg.ath.cx> <87tx9sxpuc.fsf@free.fr> <87ioq81e9x.fsf@bzg.ath.cx> <87mwfkxnpe.fsf@free.fr> <87wqeo2qcs.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wam4k-0007Mu-Ad for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 09:10:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wam4f-0001IF-PU for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 09:09:58 -0400 In-Reply-To: <87wqeo2qcs.fsf@bzg.ath.cx> (Bastien's message of "Thu, 17 Apr 2014 12:38:11 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode@gnu.org 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.