summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-06-22 15:28:05 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-06-22 15:31:48 +0200
commit5cd793c59a7727f7bd0a1639fcde2eae6f6d1cf0 (patch)
treedc8ad74f94a2521dbb3afd5cdb14eb04a62c8be0
parent6b7944805f9fe6536c6d3657694c8885cc2b8a42 (diff)
downloadorg-mode-5cd793c59a7727f7bd0a1639fcde2eae6f6d1cf0.tar.gz
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 <arunisaac@systemreboot.net> <http://permalink.gmane.org/gmane.emacs.orgmode/107856>
-rw-r--r--doc/org.texi10
-rw-r--r--etc/ORG-NEWS5
-rw-r--r--lisp/ox-publish.el20
3 files changed, 21 insertions, 14 deletions
diff --git a/doc/org.texi b/doc/org.texi
index 9a0c0b7..f75c649 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 816d9d3..ea9e4de 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 8ccba99..cde63ff 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)