瀏覽代碼

Publishing: Clean out timestamp directory with `C-u C-c C-e E'

When changing the publishing setup, old timestamp files can be left
behind.  Forcing publishing of all projects with `C-u C-c C-e E'
will remove all existing timestamp files.
Carsten Dominik 16 年之前
父節點
當前提交
67d2a22fb9
共有 3 個文件被更改,包括 21 次插入5 次删除
  1. 4 4
      doc/org.texi
  2. 4 0
      lisp/ChangeLog
  3. 13 1
      lisp/org-publish.el

+ 4 - 4
doc/org.texi

@@ -9881,10 +9881,10 @@ Publish every project.
 @vindex org-publish-use-timestamps-flag
 Org uses timestamps to track when a file has changed. The above functions
 normally only publish changed files. You can override this and force
-publishing of all files by giving a prefix argument, or by customizing the
-variable @code{org-publish-use-timestamps-flag}.  This may be necessary in
-particular if files include other files via @code{#+SETUPFILE:} or
-@code{#+INCLUDE:}.
+publishing of all files by giving a prefix argument to any of the commands
+above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
+This may be necessary in particular if files include other files via
+@code{#+SETUPFILE:} or @code{#+INCLUDE:}.
 
 @node Miscellaneous, Hacking, Publishing, Top
 @chapter Miscellaneous

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2009-07-07  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-publish.el (org-publish-remove-all-timestamps): New function.
+	(org-publish-all): Remove all timestamp files if `org-publish-all'
+	is called with a prefix argument.
+
 	* org-list.el (org-indent-item): Fix typo.
 	(org-item-indent-positions): Normalize ordered bullet.
 

+ 13 - 1
lisp/org-publish.el

@@ -244,6 +244,15 @@ If there is no timestamp, create one."
 	(set-file-times timestamp-file)
       (call-process "touch" nil 0 nil (expand-file-name timestamp-file)))))
 
+(defun org-publish-remove-all-timestamps ()
+  "Remove all files in the timstamp directory."
+  (let ((dir org-publish-timestamp-directory)
+	files)
+    (when (and (file-exists-p dir)
+	       (file-directory-p dir))
+      (mapc 'delete-file (directory-files dir 'full "[^.]\\'")))))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Mapping files to project names
 
@@ -631,8 +640,11 @@ Default for INDEX-FILENAME is 'sitemap.org'."
 ;;;###autoload
 (defun org-publish-all (&optional force)
   "Publish all projects.
-With prefix argument, force publish all files."
+With prefix argument, remove all files in the timestamp
+directory and force publishing all files."
   (interactive "P")
+  (when force
+    (org-publish-remove-all-timestamps))
   (org-publish-initialize-files-alist)
   (save-window-excursion
     (let ((org-publish-use-timestamps-flag