فهرست منبع

ox-publish: Raise an error when encountering undefined component

* lisp/ox-publish.el (org-publish-expand-projects): Raise an error
  when encountering undefined component.  Refactor code.  Fix
  docstring.

Reported-by: Bob Newell <bobnewell@bobnewell.net>
<http://permalink.gmane.org/gmane.emacs.orgmode/112712>
Nicolas Goaziou 8 سال پیش
والد
کامیت
6e1d174d0a
1فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 11 10
      lisp/ox-publish.el

+ 11 - 10
lisp/ox-publish.el

@@ -413,16 +413,17 @@ project base directory."
 
 (defun org-publish-expand-projects (projects-alist)
   "Expand projects in PROJECTS-ALIST.
-This splices all the components into the list."
-  (let ((rest projects-alist) rtn p components)
-    (while (setq p (pop rest))
-      (if (setq components (plist-get (cdr p) :components))
-	  (setq rest (append
-		      (mapcar (lambda (x) (assoc x org-publish-project-alist))
-			      components)
-		      rest))
-	(push p rtn)))
-    (nreverse (delete-dups (delq nil rtn)))))
+This splices all the components into a list."
+  (delete-dups
+   (cl-mapcan (lambda (project)
+		(pcase-let ((`(,name . ,properties) project))
+		  (cl-mapcan (lambda (component)
+			       (or
+				(assoc component org-publish-project-alist)
+				(user-error "Unknown component %S in project %S"
+					    component name)))
+			     (plist-get properties :components))))
+	      projects-alist)))
 
 (defun org-publish-get-base-files (project)
   "Return a list of all files in PROJECT."