]> code.delx.au - gnu-emacs/blobdiff - lisp/org/ox-publish.el
Update copyright year to 2015
[gnu-emacs] / lisp / org / ox-publish.el
index 67a57fa38ffe34cb225504a0344252238e0525ee..f35df1b2a9c7044b84f124a9ee67afd56a0c9c65 100644 (file)
@@ -1,5 +1,5 @@
 ;;; ox-publish.el --- Publish Related Org Mode Files as a Website
-;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
 
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
@@ -228,7 +228,7 @@ If you create a site-map file, adjust the sorting like this:
   `:sitemap-sort-files'
 
     The site map is normally sorted alphabetically.  You can
-    change this behaviour setting this to `anti-chronologically',
+    change this behavior setting this to `anti-chronologically',
     `chronologically', or nil.
 
   `:sitemap-ignore-case'
@@ -805,10 +805,16 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
          (visiting (find-buffer-visiting file))
          (buffer (or visiting (find-file-noselect file))))
      (with-current-buffer buffer
-       (org-mode)
        (let ((title
-             (let ((property (plist-get (org-export-get-environment) :title)))
-               (if property (org-element-interpret-data property)
+             (let ((property
+                    (plist-get
+                     ;; protect local variables in open buffers
+                     (if visiting
+                         (org-export-with-buffer-copy (org-export-get-environment))
+                       (org-export-get-environment))
+                     :title)))
+               (if property
+                   (org-no-properties (org-element-interpret-data property))
                  (file-name-nondirectory (file-name-sans-extension file))))))
         (unless visiting (kill-buffer buffer))
         (org-publish-cache-set-file-property file :title title)
@@ -821,12 +827,14 @@ 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))
+    (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
-                   (let ((org-inhibit-startup t)) (org-mode))
-                   (org-export-get-environment))
+                   (if visiting
+                       (org-export-with-buffer-copy (org-export-get-environment))
+                     (org-export-get-environment)))
                  :date)))
       (unless visiting (kill-buffer file-buf))
       ;; DATE is either a timestamp object or a secondary string.  If it
@@ -873,7 +881,7 @@ publishing will be done asynchronously, in another process."
                          ;; project is still a string here.
                          (list (assoc project org-publish-project-alist)))))
     (if async
-       (org-export-async-start 'ignore
+       (org-export-async-start (lambda (results) nil)
          `(let ((org-publish-use-timestamps-flag
                  (if ',force nil ,org-publish-use-timestamps-flag)))
             (org-publish-projects ',project-alist)))
@@ -891,7 +899,7 @@ optional argument ASYNC, publishing will be done asynchronously,
 in another process."
   (interactive "P")
   (if async
-      (org-export-async-start 'ignore
+      (org-export-async-start (lambda (results) nil)
        `(progn
           (when ',force (org-publish-remove-all-timestamps))
           (let ((org-publish-use-timestamps-flag
@@ -913,7 +921,7 @@ asynchronously, in another process."
   (interactive "P")
   (let ((file (buffer-file-name (buffer-base-buffer))))
     (if async
-       (org-export-async-start 'ignore
+       (org-export-async-start (lambda (results) nil)
          `(let ((org-publish-use-timestamps-flag
                  (if ',force nil ,org-publish-use-timestamps-flag)))
             (org-publish-file ,file)))
@@ -1072,7 +1080,7 @@ publishing directory."
 Return value is a list of numbers, or nil.  This function allows
 to resolve external fuzzy links like:
 
-  [[file.org::*fuzzy][description]"
+  [[file.org::*fuzzy][description]]"
   (when org-publish-cache
     (cdr (assoc (org-split-string
                 (if (eq (aref fuzzy 0) ?*) (substring fuzzy 1) fuzzy))
@@ -1225,8 +1233,9 @@ Returns value on success, else nil."
   (let ((attr (file-attributes
               (expand-file-name (or (file-symlink-p file) file)
                                 (file-name-directory file)))))
-    (+ (lsh (car (nth 5 attr)) 16)
-       (cadr (nth 5 attr)))))
+    (if (not attr) (error "No such file: \"%s\"" file)
+      (+ (lsh (car (nth 5 attr)) 16)
+        (cadr (nth 5 attr))))))
 
 
 (provide 'ox-publish)