summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-07-12 15:09:58 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2013-07-12 15:09:58 +0200
commit7fcf4995afe87deae583c5e23c6318b36b139d25 (patch)
treebfa98240175d5c3f1839b1d6eb5b4b72d021c912
parent956837087b8b6be773018d09c71b7f485a6bf82d (diff)
downloadorg-mode-7fcf4995afe87deae583c5e23c6318b36b139d25.tar.gz
ox-publish: Fix :recursive parameter ignoring extension restriction
* lisp/ox-publish.el (org-publish-find-date): Also return date for directories. (org-publish-get-base-files-1): Fix :recursive parameter ignoring extension restriction.
-rw-r--r--lisp/ox-publish.el64
1 files changed, 36 insertions, 28 deletions
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index cf428d1..d5f4dfe 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -449,10 +449,16 @@ matching the regexp SKIP-DIR when recursing through BASE-DIR."
(not (string-match match fnd)))
(pushnew f org-publish-temp-files)))))
- (if org-sitemap-requested
- (sort (directory-files base-dir t (unless recurse match))
- 'org-publish-compare-directory-files)
- (directory-files base-dir t (unless recurse match)))))
+ (let ((all-files (if (not recurse) (directory-files base-dir t match)
+ ;; If RECURSE is non-nil, we want all files
+ ;; matching MATCH and sub-directories.
+ (org-remove-if-not
+ (lambda (file)
+ (or (file-directory-p file)
+ (and match (string-match match file))))
+ (directory-files base-dir t)))))
+ (if (not org-sitemap-requested) all-files
+ (sort all-files 'org-publish-compare-directory-files)))))
(defun org-publish-get-base-files (project &optional exclude-regexp)
"Return a list of all files in PROJECT.
@@ -811,30 +817,32 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
(defun org-publish-find-date (file)
"Find the date of FILE in project.
-If FILE provides a DATE keyword use it else use the file system's
-modification time. Return time in `current-time' format."
- (let* ((org-inhibit-startup t)
- (visiting (find-buffer-visiting file))
- (file-buf (or visiting (find-file-noselect file nil)))
- (date (plist-get
- (with-current-buffer file-buf
- (org-mode)
- (org-export-get-environment))
- :date)))
- (unless visiting (kill-buffer file-buf))
- ;; DATE is either a timestamp object or a secondary string. If it
- ;; is a timestamp or if the secondary string contains a timestamp,
- ;; convert it to internal format. Otherwise, use FILE
- ;; modification time.
- (cond ((eq (org-element-type date) 'timestamp)
- (org-time-string-to-time (org-element-interpret-data date)))
- ((let ((ts (and (consp date) (assq 'timestamp date))))
- (and ts
- (let ((value (org-element-interpret-data ts)))
- (and (org-string-nw-p value)
- (org-time-string-to-time value))))))
- ((file-exists-p file) (nth 5 (file-attributes file)))
- (t (error "No such file: \"%s\"" file)))))
+This function assumes FILE is either a directory or an Org file.
+If FILE is an Org file and provides a DATE keyword use it. In
+any other case use the file system's modification time. Return
+time in `current-time' format."
+ (if (file-directory-p file) (nth 5 (file-attributes file))
+ (let* ((visiting (find-buffer-visiting file))
+ (file-buf (or visiting (find-file-noselect file nil)))
+ (date (plist-get
+ (with-current-buffer file-buf
+ (let ((org-inhibit-startup t)) (org-mode))
+ (org-export-get-environment))
+ :date)))
+ (unless visiting (kill-buffer file-buf))
+ ;; DATE is either a timestamp object or a secondary string. If it
+ ;; is a timestamp or if the secondary string contains a timestamp,
+ ;; convert it to internal format. Otherwise, use FILE
+ ;; modification time.
+ (cond ((eq (org-element-type date) 'timestamp)
+ (org-time-string-to-time (org-element-interpret-data date)))
+ ((let ((ts (and (consp date) (assq 'timestamp date))))
+ (and ts
+ (let ((value (org-element-interpret-data ts)))
+ (and (org-string-nw-p value)
+ (org-time-string-to-time value))))))
+ ((file-exists-p file) (nth 5 (file-attributes file)))
+ (t (error "No such file: \"%s\"" file))))))