瀏覽代碼

Updated org-publish.el (now version 1.81)

Updated the ChangeLog and the manual accordingly.
Bastien Guerry 17 年之前
父節點
當前提交
8ea076e2de
共有 3 個文件被更改,包括 67 次插入55 次删除
  1. 24 0
      ChangeLog
  2. 29 47
      org-publish.el
  3. 14 8
      org.texi

+ 24 - 0
ChangeLog

@@ -1,3 +1,27 @@
+2008-03-03  Bastien Guerry  <bzg@altern.org>
+
+	* org-publish.el (org-publish-org-to, org-publish-org-to-latex)
+	(org-publish-org-to-html): New argument `pub-dir' for temporary
+	publication directory.
+	(org-publish-projects): Renamed from `org-publish-plists'.
+	(org-publish, org-publish-all): Use `org-publish-projects'.
+	(org-publish-all, org-publish-current-file)
+	(org-publish-files-alist): Renamed from `org-publish-files'.
+	(org-publish-initialize-files-alist): New defun.
+	(org-publish-current-project): First initialize the list of
+	publishable files with`org-publish-initialize-files-alist'.
+	(org-publish-get-files): New defun.
+	(org-publish-expand-projects): New defun.
+	(org-publish-expand-components): New defun.
+	(org-publish-get-base-files): Get files recursively.
+	(org-publish-update-timestamp): Create the timestamp file.
+	(org-publish-needed-p): Removed the code about creating/updating
+	the timestamp file.
+	(org-publish-validate-link)
+	(org-publish-get-plists-from-filename, org-publish-get-plists):
+	Deleted.
+	(org-publish-timestamp-directory): Use directory type.
+
 2008-03-01  Bastien Guerry  <bzg@altern.org>
 
 	* org.el (org-dblock-write:columnview, org-columns-capture-view):

+ 29 - 47
org-publish.el

@@ -5,7 +5,7 @@
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 1.80c+
+;; Version: 1.81
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -79,6 +79,7 @@
 ;; 		     :publishing-directory "~/public_html"
 ;;                   :with-section-numbers nil
 ;; 		     :table-of-contents nil
+;;                   :recursive t
 ;; 		     :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">")))
 
 ;;;; More complex example configuration:
@@ -110,12 +111,10 @@
 ;; 		       :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">"
 ;; 		       :auto-preamble t
 ;; 		       :auto-postamble nil)
-;;
 ;;         ("images" :base-directory "~/images/"
 ;; 	             :base-extension "jpg\\|gif\\|png"
 ;; 		     :publishing-directory "/ssh:user@host:~/html/images/"
 ;; 		     :publishing-function org-publish-attachment)
-;;
 ;;         ("other"  :base-directory "~/other/"
 ;; 	   	     :base-extension "css"
 ;; 		     :publishing-directory "/ssh:user@host:~/html/other/"
@@ -151,12 +150,6 @@
 
 ;;; Code:
 
-;; FIXME Mention this in the ChangeLog
-
-;; - removed org-publish-validate-link 
-;; - deleted org-publish-get-plists-from-filename
-;; - deleted org-publish-get-plists
-
 (eval-when-compile
   (require 'cl))
 
@@ -279,7 +272,7 @@ files."
 (defcustom org-publish-timestamp-directory "~/.org-timestamps/"
   "Name of directory in which to store publishing timestamps."
   :group 'org-publish
-  :type 'string)
+  :type 'directory)
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -287,59 +280,52 @@ files."
 
 (defun org-publish-timestamp-filename (filename)
   "Return path to timestamp file for filename FILENAME."
-  (while (string-match (if (eq system-type 'windows-nt) "~\\|/\\|:" "~\\|/")
-		       filename)
+  (while (string-match 
+	  (if (eq system-type 'windows-nt) "~\\|/\\|:" "~\\|/") filename)
     (setq filename (replace-match "_" nil t filename)))
   (concat org-publish-timestamp-directory filename ".timestamp"))
 
-;; FIXME ChangeLog: deleted :parents 
 (defun org-publish-needed-p (filename)
-  "Check whether file should be published.
-If org-publish-use-timestamps-flag is set to nil, this function always
-returns t. Otherwise, check the timestamps folder to determine
-whether file should be published."
+  "Return `t' if FILENAME should be published."
   (if org-publish-use-timestamps-flag
-      (progn
-	;; create folder if needed
-	(if (not (file-exists-p org-publish-timestamp-directory))
-	    (make-directory org-publish-timestamp-directory)
+      (if (file-exists-p org-publish-timestamp-directory)
+	  ;; first handle possible wrong timestamp directory
 	  (if (not (file-directory-p org-publish-timestamp-directory))
-	      (error "`org-publish-timestamp-directory' must be a directory")))
-	;; check timestamp. ok if timestamp file doesn't exist
-	(let* ((timestamp (org-publish-timestamp-filename filename))
-	       (rtn (file-newer-than-file-p filename timestamp)))
-	  (if rtn
-	      ;; handle new timestamps
-	      (if (not (file-exists-p timestamp))
-		  ;; create file
-		  (with-temp-buffer
-		    (make-directory (file-name-directory timestamp) t)
-		    (write-file timestamp)
-		    (kill-buffer (current-buffer)))))
-	  rtn))
-    ;; always return `t' is we don't use timestamp
+	      (error "Org publish timestamp: %s is not a directory"
+		     org-publish-timestamp-directory)
+	    ;; there is a timestamp, check if FILENAME is newer
+	    (file-newer-than-file-p
+	     filename (org-publish-timestamp-filename filename))))
+    ;; don't use timestamps, always return t
     t))
 
 (defun org-publish-update-timestamp (filename)
-  "Update publishing timestamp for file FILENAME."
-  (let ((timestamp (org-publish-timestamp-filename filename)))
-    ;; Emacs 21 doesn't have set-file-times
-    (if (fboundp 'set-file-times)
-        (set-file-times timestamp)
-      (call-process "touch" nil 0 nil timestamp))))
+  "Update publishing timestamp for file FILENAME.
+If there is no timestamp, create one."
+  (let ((timestamp-file (org-publish-timestamp-filename filename))
+	newly-created-timestamp)
+    (if (not (file-exists-p timestamp-file))
+	;; create timestamp file if needed
+	(with-temp-buffer
+	  (make-directory (file-name-directory timestamp-file) t)
+	  (write-file timestamp-file)
+	  (setq newly-created-timestamp t)))
+    ;; Emacs 21 doesn't have `set-file-times'
+    (if (and (fboundp 'set-file-times)
+	     (not newly-created-timestamp))
+        (set-file-times timestamp-file)
+      (call-process "touch" nil 0 nil timestamp-file))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Mapping files to project names
 
-;; FIXME ChangeLog: renamed from org-publish-files
 (defvar org-publish-files-alist nil
   "Alist of files and their parent project.
 Each element of this alist is of the form:
 
   (file-name . project-name)")
 
-;; FIXME ChangeLog: new defun
 (defun org-publish-initialize-files-alist (&optional refresh)
   "Set `org-publish-files-alist' if it is not set.
 Also set it if the optional argument REFRESH is non-nil."
@@ -351,7 +337,6 @@ Also set it if the optional argument REFRESH is non-nil."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Getting project information out of org-publish-project-alist
 
-;; FIXME ChangeLog: new defun
 (defun org-publish-get-files (projects-alist &optional no-exclusion)
   "Return the list of all publishable files for PROJECTS-ALIST.
 If NO-EXCLUSION is non-nil, don't exclude files."
@@ -369,7 +354,6 @@ If NO-EXCLUSION is non-nil, don't exclude files."
      (org-publish-expand-projects projects-alist))
     all-files))
 
-;; ;; FIXME ChangeLog: new defun
 (defun org-publish-expand-projects (projects-alist)
   "Expand projects contained in PROJECTS-ALIST."
   (let (without-component with-component)
@@ -383,7 +367,6 @@ If NO-EXCLUSION is non-nil, don't exclude files."
 	     (car (mapcar (lambda(p) (org-publish-expand-components p))
 			  with-component))))))
 
-;; FIXME ChangeLog: new defun
 (defun org-publish-expand-components (project)
   "Expand PROJECT into an alist of its components."
   (let* ((components (plist-get (cdr project) :components)))
@@ -602,6 +585,5 @@ the project."
 
 (provide 'org-publish)
 
-
 ;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
 ;;; org-publish.el ends here

+ 14 - 8
org.texi

@@ -7013,14 +7013,16 @@ the two following forms:
 
 @end lisp
 
-In both cases, projects are configured by specifying property values.
-A project defines the set of files that will be published, as well as
-the publishing configuration to use when publishing those files.  When
-a project takes the second form listed above, the individual members
-of the ``components'' property are taken to be components of the
-project, which group together files requiring different publishing
-options. When you publish such a ``meta-project'' all the components
-will also publish.
+In both cases, projects are configured by specifying property values.  A
+project defines the set of files that will be published, as well as the
+publishing configuration to use when publishing those files.  When a
+project takes the second form listed above, the individual members of
+the ``components'' property are taken to be components of the project,
+which group together files requiring different publishing options.  When
+you publish such a ``meta-project'' all the components will also be
+published.
+
+For now, components are not allowed to have components themselves.
 
 @node Sources and destinations, Selecting files, Project alist, Configuration
 @subsection Sources and destinations for files
@@ -7061,6 +7063,10 @@ extension.
 @item @code{:include}
 @tab List of files to be included regardless of @code{:base-extension}
 and @code{:exclude}.
+
+@item @code{:recursive}
+@tab When non-@code{nil}, the @code{:base-directory} will be recursively
+published.
 @end multitable
 
 @node Publishing action, Publishing options, Selecting files, Configuration