|
@@ -1,5 +1,4 @@
|
|
|
;;; org-publish.el --- publish related org-mode files as a website
|
|
|
-
|
|
|
;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
|
|
|
|
|
|
;; Author: David O'Toole <dto@gnu.org>
|
|
@@ -157,8 +156,6 @@
|
|
|
(unless (fboundp 'declare-function)
|
|
|
(defmacro declare-function (fn file &optional arglist fileonly))))
|
|
|
|
|
|
-(require 'dired-aux)
|
|
|
-
|
|
|
(defgroup org-publish nil
|
|
|
"Options for publishing a set of Org-mode and related files."
|
|
|
:tag "Org Publishing"
|
|
@@ -346,6 +343,8 @@ Each element of this alist is of the form:
|
|
|
|
|
|
(defvar org-publish-initial-buffer nil
|
|
|
"The buffer `org-publish' has been called from.")
|
|
|
+(defvar org-publish-temp-files nil
|
|
|
+ "Temporary list of files to be published.")
|
|
|
|
|
|
(defun org-publish-initialize-files-alist (&optional refresh)
|
|
|
"Set `org-publish-files-alist' if it is not set.
|
|
@@ -417,6 +416,24 @@ If NO-EXCLUSION is non-nil, don't exclude files."
|
|
|
(delq nil (mapcar (lambda(c) (assoc c org-publish-project-alist))
|
|
|
components)))))
|
|
|
|
|
|
+(defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir)
|
|
|
+ "Set `org-publish-temp-files' with files from BASE-DIR directory.
|
|
|
+If RECURSE is non-nil, check BASE-DIR recursively. If MATCH is
|
|
|
+non-nil, restrict this list to the files matching the regexp
|
|
|
+MATCH. If SKIP-FILE is non-nil, skip file matching the regexp
|
|
|
+SKIP-FILE. If SKIP-DIR is non-nil, don't check directories
|
|
|
+matching the regexp SKIP-DIR when recursiing through BASE-DIR."
|
|
|
+ (mapc (lambda (f)
|
|
|
+ (let ((fd-p (car (file-attributes f)))
|
|
|
+ (fnd (file-name-nondirectory f)))
|
|
|
+ (if (and fd-p recurse
|
|
|
+ (not (string-match "^\\.+$" fnd))
|
|
|
+ (if skip-dir (not (string-match match skip-dir fnd)) t))
|
|
|
+ (org-publish-get-base-files-1 f recurse skip-file skip-dir)
|
|
|
+ (unless (or fd-p (and skip-file (string-match skip-file fnd)))
|
|
|
+ (pushnew f org-publish-temp-files)))))
|
|
|
+ (directory-files base-dir t match)))
|
|
|
+
|
|
|
(defun org-publish-get-base-files (project &optional exclude-regexp)
|
|
|
"Return a list of all files in PROJECT.
|
|
|
If EXCLUDE-REGEXP is set, this will be used to filter out
|
|
@@ -425,33 +442,12 @@ matching filenames."
|
|
|
(base-dir (file-name-as-directory
|
|
|
(plist-get project-plist :base-directory)))
|
|
|
(include-list (plist-get project-plist :include))
|
|
|
- (recursive-p (plist-get project-plist :recursive))
|
|
|
+ (recurse (plist-get project-plist :recursive))
|
|
|
(extension (or (plist-get project-plist :base-extension) "org"))
|
|
|
- (regexp (concat "^[^\\.].*\\.\\(" extension "\\)$"))
|
|
|
- alldirs allfiles files dir)
|
|
|
- ;; Get all files and directories in base-directory
|
|
|
- (setq files (dired-files-attributes base-dir))
|
|
|
- ;; Get all subdirectories if recursive-p
|
|
|
- (setq alldirs
|
|
|
- (if recursive-p
|
|
|
- (delq nil (mapcar (lambda(f) (if (caaddr f) (cadr f))) files))
|
|
|
- (list base-dir)))
|
|
|
- (while (setq dir (pop alldirs))
|
|
|
- (setq files (directory-files dir t regexp))
|
|
|
- ;; Exclude files
|
|
|
- (setq files
|
|
|
- (if (not exclude-regexp)
|
|
|
- files
|
|
|
- (delq nil
|
|
|
- (mapcar (lambda (x)
|
|
|
- (if (string-match exclude-regexp x) nil x))
|
|
|
- files))))
|
|
|
- ;; Include extra files
|
|
|
- (let (inc)
|
|
|
- (while (setq inc (pop include-list))
|
|
|
- (setq files (cons (expand-file-name inc dir) files))))
|
|
|
- (setq allfiles (append allfiles files)))
|
|
|
- allfiles))
|
|
|
+ (match (concat "^[^\\.].*\\.\\(" extension "\\)$")))
|
|
|
+ (setq org-publish-temp-files nil)
|
|
|
+ (org-publish-get-base-files-1 base-dir recurse match exclude-regexp)
|
|
|
+ org-publish-temp-files))
|
|
|
|
|
|
(defun org-publish-get-project-from-filename (filename)
|
|
|
"Return the project FILENAME belongs."
|