emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* :completion function isn't run anymore?
@ 2015-11-26 23:01 Julien Cubizolles
  2015-11-27 15:49 ` Julien Cubizolles
  0 siblings, 1 reply; 7+ messages in thread
From: Julien Cubizolles @ 2015-11-26 23:01 UTC (permalink / raw)
  To: emacs-orgmode


I noticed that the :preparation-function defined in
org-publish-project-alist isn't run anymore when publishing a project.

Consider the following, it's a stripped-down version of the setup I have
been using on many documents for a few years.

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp :tangle none :exports none
  (setq org-export-in-background nil)
  (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 (suffix version)
    "Rename file.suffix to file-version.suffix when buffer is visiting file.org"
    (let*   ((file-base-name (remove-org-suffix (buffer-file-name)))
             (file-suffix-name (concat file-base-name "." suffix))
             (file-version-suffix-name (concat file-base-name "-" version  "." suffix)))
    (if (file-exists-p file-suffix-name)
        (rename-file file-suffix-name file-version-suffix-name t))
    )
    )
  (defun jc-org-publish-rename-pdf (suffix)
    "Rename file.pdf to file-suffix.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-suffix-pdf-name (concat file-base-name "-" suffix  ".pdf")))
  (if (file-exists-p file-pdf-name)
      (rename-file file-pdf-name file-suffix-pdf-name 1))
    )
  )
  (defun jc-org-publish-rename-beamer-pdf ()
  "Rename file.pdf to file-beamer.pdf and file.tex to file-beamer.tex when buffer is visiting file.org"
  (jc-org-publish-rename '"pdf" '"beamer")
  (jc-org-publish-rename '"tex" '"beamer"))

  (setq org-publish-project-alist
        `(("beamer"
           :base-directory "./"
           :publishing-directory "./"
           :publishing-function org-beamer-publish-to-pdf
           :exclude ".*"
           :include ,(list (file-name-nondirectory buffer-file-name))
           :completion-function jc-org-publish-rename-beamer-pdf
           )
          ))
#+end_src

#+RESULTS:
| beamer | :base-directory | ./ | :publishing-directory | ./ | :publishing-function | org-beamer-publish-to-pdf | :exclude | .* | :include | (test.org) | :completion-function | jc-org-publish-rename-beamer-pdf |

* 1st section
** 1st subsection
** 2nd subsection
--8<---------------cut here---------------end--------------->8---

Save the to test.org and publish using the "beamer"
project. org-beamer-publish-to-pdf creates test.pdf as it should but the
completion-function should rename test.tex and test.pdf test-beamer.tex
and test-beamer.pdf. It doesn't. Even worse, you can type whatever
function name for :completion-function, even if it's not defined, and
the exporter won't complain.

However, with emacs -Q (and the version of org-mode shipped with it), I
recover the expected behaviour

With  emacs -Q -l ~/test.el, the problem reoccurs

~/test.el
--8<---------------cut here---------------start------------->8---
(add-to-list 'load-path "~/info/emacs/org-mode/lisp")
(add-to-list 'load-path "~/info/emacs/org-mode/contrib/lisp")
--8<---------------cut here---------------end--------------->8---
~/info/emacs/org-mode/ is my git repo of org-mode.

I'm running GNU Emacs 25.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.14.13) of 2015-10-21

Julien.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-29 21:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26 23:01 :completion function isn't run anymore? Julien Cubizolles
2015-11-27 15:49 ` Julien Cubizolles
2015-11-29 13:20   ` Nicolas Goaziou
2015-11-29 20:38     ` Julien Cubizolles
2015-11-29 20:53       ` Nicolas Goaziou
2015-11-29 21:19         ` Julien Cubizolles
2015-11-29 21:39           ` Nicolas Goaziou

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).