From 5cd793c59a7727f7bd0a1639fcde2eae6f6d1cf0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 22 Jun 2016 15:28:05 +0200 Subject: [PATCH] ox-publish: Change signature for preparation and completion functions * doc/org.texi (Sources and destinations): Document new signature. * lisp/ox-publish.el (org-publish-project-alist): Update docstring. (org-publish-projects): Call preparation and completion functions with the project properties as the sole argument. `project-plist' used to be dynamically scoped. This is no longer possible due to the switch to lexical binding. Reported-by: Arun Isaac --- doc/org.texi | 10 +++++----- etc/ORG-NEWS | 5 ++++- lisp/ox-publish.el | 20 ++++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 9a0c0b7ab..f75c649e4 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -14250,13 +14250,13 @@ use external tools to upload your website (@pxref{Uploading files}). @item @code{:preparation-function} @tab Function or list of functions to be called before starting the publishing process, for example, to run @code{make} for updating files to be -published. The project property list is scoped into this call as the -variable @code{project-plist}. +published. Each preparation function is called with a single argument, the +project property. @item @code{:completion-function} @tab Function or list of functions called after finishing the publishing -process, for example, to change permissions of the resulting files. The -project property list is scoped into this call as the variable -@code{project-plist}. +process, for example, to change permissions of the resulting files. Each +completion function is called with a single argument, the project property +list. @end multitable @noindent diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 816d9d363..ea9e4de7a 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -104,10 +104,13 @@ is straightforward. For example becomes : ("pdf" . (lambda (file link) (foo))) - *** The ~{{{modification-time}}}~ macro can obtain time via =vc= The modification time will be determined via =vc.el= if the second argument is non-nil. See the manual for details. +*** Preparation and completion functions in publishing projects change signature +Preparation and completion functions are now called with an argument, +which is the project property list. It used to be dynamically scoped +through the ~project-plist~ variable. ** New features *** New org-protocol key=value syntax diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 8ccba9945..cde63ff21 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -144,12 +144,16 @@ date. `:preparation-function' Function to be called before publishing this project. This - may also be a list of functions. + may also be a list of functions. Preparation functions are + called with the project properties list as their sole + argument. `:completion-function' Function to be called after publishing this project. This - may also be a list of functions. + may also be a list of functions. Completion functions are + called with the project properties list as their sole + argument. Some properties control details of the Org publishing process, and are equivalent to the corresponding user variables listed in @@ -673,9 +677,9 @@ If `:auto-sitemap' is set, publish the sitemap too. If `:makeindex' is set, also produce a file \"theindex.org\"." (dolist (project (org-publish-expand-projects projects)) (let ((project-plist (cdr project))) - (let ((f (plist-get project-plist :preparation-function))) - (cond ((consp f) (mapc #'funcall f)) - ((functionp f) (funcall f)))) + (let ((fun (plist-get project-plist :preparation-function))) + (cond ((consp fun) (dolist (f fun) (funcall f project-plist))) + ((functionp fun) (funcall fun project-plist)))) ;; Each project uses its own cache file. (org-publish-initialize-cache (car project)) (when (plist-get project-plist :auto-sitemap) @@ -707,9 +711,9 @@ If `:auto-sitemap' is set, publish the sitemap too. If (org-publish-index-generate-theindex project (plist-get project-plist :base-directory)) (org-publish-file theindex project t))) - (let ((f (plist-get project-plist :completion-function))) - (cond ((consp f) (mapc #'funcall f)) - ((functionp f) (funcall f)))) + (let ((fun (plist-get project-plist :completion-function))) + (cond ((consp fun) (dolist (f fun) (funcall f project-plist))) + ((functionp fun) (funcall fun project-plist)))) (org-publish-write-cache-file)))) (defun org-publish-org-sitemap (project &optional sitemap-filename)