瀏覽代碼

Added the alias `org-publish-delete-duplicates'.

In (< emacs-major-version 2), there is no `delete-dups'.
So we use this alias, either calling `delete-dups' or
using a routine copyied from subr.el in Emacs 22+.
Bastien Guerry 17 年之前
父節點
當前提交
bc59617af7
共有 1 個文件被更改,包括 18 次插入2 次删除
  1. 18 2
      org-publish.el

+ 18 - 2
org-publish.el

@@ -356,6 +356,22 @@ If NO-EXCLUSION is non-nil, don't exclude files."
      (org-publish-expand-projects projects-alist))
     all-files))
 
+(if (fboundp 'delete-dups)
+    (defalias 'org-publish-delete-duplicates 'delete-dups)
+  (defun org-publish-delete-duplicates (list)
+    "Destructively remove `equal' duplicates from LIST.
+Store the result in LIST and return it.  LIST must be a proper list.
+Of several `equal' occurrences of an element in LIST, the first
+one is kept.
+
+This is a compatibility function for Emacsen without `delete-dups'."
+    ;; Code from `subr.el' in Emacs 22:
+    (let ((tail list))
+      (while tail
+	(setcdr tail (delete (car tail) (cdr tail)))
+	(setq tail (cdr tail))))
+    list))
+
 (defun org-publish-expand-projects (projects-alist)
   "Expand projects contained in PROJECTS-ALIST."
   (let (without-component with-component)
@@ -364,7 +380,7 @@ If NO-EXCLUSION is non-nil, don't exclude files."
 	     (if (plist-get (cdr p) :components)
 		 'with-component 'without-component) p))
 	  projects-alist)
-    (delete-dups
+    (org-publish-delete-duplicates
      (append without-component
 	     (car (mapcar (lambda(p) (org-publish-expand-components p))
 			  with-component))))))
@@ -372,7 +388,7 @@ If NO-EXCLUSION is non-nil, don't exclude files."
 (defun org-publish-expand-components (project)
   "Expand PROJECT into an alist of its components."
   (let* ((components (plist-get (cdr project) :components)))
-    (delete-dups 
+    (org-publish-delete-duplicates
      (mapcar (lambda(c) (assoc c org-publish-project-alist))
 	     components))))