From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Cubizolles Subject: Re: Using Buffer name in :include export property Date: Fri, 29 Aug 2014 11:40:07 +0200 Message-ID: <87k35reirs.fsf@free.fr> References: <87y4u8s3c6.fsf@free.fr> <871ts0yzdq.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNIfQ-00083u-5W for emacs-orgmode@gnu.org; Fri, 29 Aug 2014 05:40:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNIfK-0000zV-Ta for emacs-orgmode@gnu.org; Fri, 29 Aug 2014 05:40:24 -0400 Received: from plane.gmane.org ([80.91.229.3]:44964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNIfK-0000zO-Mr for emacs-orgmode@gnu.org; Fri, 29 Aug 2014 05:40:18 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XNIfJ-0000g3-Gr for emacs-orgmode@gnu.org; Fri, 29 Aug 2014 11:40:17 +0200 Received: from gas45-3-82-244-252-119.fbx.proxad.net ([82.244.252.119]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Aug 2014 11:40:17 +0200 Received: from j.cubizolles by gas45-3-82-244-252-119.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Aug 2014 11:40:17 +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: emacs-orgmode@gnu.org Nick Dokos writes: > Julien Cubizolles writes: > >> I'm using the following elisp source block in my org files to choose the >> publication options. >> >> (setq org-publish-project-alist >> '(("TeX" >> :base-directory "./" >> :publishing-directory "./" >> :publishing-function org-beamer-publish-to-latex >> :exclude ".*" >> :latex-class "mpsi_beamer" >> :include ("test.org")) >> )) >> >> I'd like to define it once and for all in my emacs >> configuration files but I'd need to replace the >> >> :include ("test.org") >> >> line with the result of (buffer-name). Is it possible ? >> > > Do you mean buffer-file-name? Yes that's better. > When you publish a project, it does not matter what your current buffer > is. So why would you want to include the random file that you just > happen to be visiting? And what if the buffer is not associated with a > file at all (so buffer-file-name returns nil)? > Can you explain what exactly you are trying to do? I need to export the same org file with different latex classes and package options. I do so by using different projects for the same file. > The usual method of splicing in a variable into a list is with > backquote - see e.g. > > http://thread.gmane.org/gmane.emacs.orgmode/9583/focus=9603 > > but I don't think that would work here in any case. Thanks for the pointer, it works: --8<---------------cut here---------------start------------->8--- (defun jc-org-publish-project-options () (setq org-publish-project-alist `(("TeX" :base-directory "./" :publishing-directory "./" :publishing-function org-beamer-publish-to-latex :exclude ".*" :latex-class "mpsi_beamer" :include , (list (file-name-nondirectory buffer-file-name)) ) ( several other projects...) ))) (add-hook 'org-mode-hook 'jc-org-publish-project-options) (add-hook 'org-export-before-processing-hook 'jc-org-publish-project-options) --8<---------------cut here---------------end--------------->8--- I'm not sure file-name-nondirectory is necessary. As you can see I need to hook this function twice: - the org-mode-hook is so that the project names are available in any org file - the org-export-before-processing-hook is to adapt the :include option to each org file before export. That's not very elegant, if someone has any idea. Julien.