Explorar el Código

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>
Nicolas Goaziou hace 8 años
padre
commit
5cd793c59a
Se han modificado 3 ficheros con 21 adiciones y 14 borrados
  1. 5 5
      doc/org.texi
  2. 4 1
      etc/ORG-NEWS
  3. 12 8
      lisp/ox-publish.el

+ 5 - 5
doc/org.texi

@@ -14250,13 +14250,13 @@ use external tools to upload your website (@pxref{Uploading files}).
 @item @code{:preparation-function}
 @item @code{:preparation-function}
 @tab Function or list of functions to be called before starting the
 @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
 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}
 @item @code{:completion-function}
 @tab Function or list of functions called after finishing the publishing
 @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
 @end multitable
 @noindent
 @noindent
 
 

+ 4 - 1
etc/ORG-NEWS

@@ -104,10 +104,13 @@ is straightforward.  For example
 becomes
 becomes
 
 
 : ("pdf" . (lambda (file link) (foo)))
 : ("pdf" . (lambda (file link) (foo)))
-
 *** The ~{{{modification-time}}}~ macro can obtain time via =vc=
 *** The ~{{{modification-time}}}~ macro can obtain time via =vc=
 The modification time will be determined via =vc.el= if the second
 The modification time will be determined via =vc.el= if the second
 argument is non-nil.  See the manual for details.
 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 features
 *** New org-protocol key=value syntax
 *** New org-protocol key=value syntax
 
 

+ 12 - 8
lisp/ox-publish.el

@@ -144,12 +144,16 @@ date.
   `:preparation-function'
   `:preparation-function'
 
 
     Function to be called before publishing this project.  This
     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'
   `:completion-function'
 
 
     Function to be called after publishing this project.  This
     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,
 Some properties control details of the Org publishing process,
 and are equivalent to the corresponding user variables listed in
 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\"."
 `:makeindex' is set, also produce a file \"theindex.org\"."
   (dolist (project (org-publish-expand-projects projects))
   (dolist (project (org-publish-expand-projects projects))
     (let ((project-plist (cdr project)))
     (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.
       ;; Each project uses its own cache file.
       (org-publish-initialize-cache (car project))
       (org-publish-initialize-cache (car project))
       (when  (plist-get project-plist :auto-sitemap)
       (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
 	  (org-publish-index-generate-theindex
 	   project (plist-get project-plist :base-directory))
 	   project (plist-get project-plist :base-directory))
 	  (org-publish-file theindex project t)))
 	  (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))))
       (org-publish-write-cache-file))))
 
 
 (defun org-publish-org-sitemap (project &optional sitemap-filename)
 (defun org-publish-org-sitemap (project &optional sitemap-filename)