summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Lundin <mdl@imapmail.org>2014-07-29 13:35:41 -0500
committerBastien Guerry <bzg@altern.org>2014-07-29 23:20:19 +0200
commita40f568f19579924af8564ed88b74104ffa39bc7 (patch)
tree5d6fd47b9c6777cf1a8a968c2cd4ea1eb3d861e1
parentdc4942442c072748afa9fbb930636430fec9ea16 (diff)
downloadorg-mode-a40f568f19579924af8564ed88b74104ffa39bc7.tar.gz
Protect open buffers when publishing sitemaprelease_8.2.7c
* lisp/ox-publish.el: (org-publish-find-title) (org-publish-find-date) Make sure to call org-export-get-environment in copy of buffer if emacs is already visiting. Otherwise, #+bind variables meant for export can be set in live buffers. This patch also optimizes the above functions by inhibiting org-startup on buffers emacs visits temporarily.
-rw-r--r--lisp/ox-publish.el18
1 files changed, 14 insertions, 4 deletions
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 24546ea..1dc790d 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -801,11 +801,18 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
"Find the title of FILE in project."
(or
(and (not reset) (org-publish-cache-get-file-property file :title nil t))
- (let* ((visiting (find-buffer-visiting file))
+ (let* ((org-inhibit-startup t)
+ (visiting (find-buffer-visiting file))
(buffer (or visiting (find-file-noselect file))))
(with-current-buffer buffer
(let ((title
- (let ((property (plist-get (org-export-get-environment) :title)))
+ (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))))))
@@ -820,11 +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
- (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