summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-11 00:45:21 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-11 00:45:21 +0100
commitc6f9aeb06ea9a5ae4d19218a514e28b294d5cbf6 (patch)
tree1a0c60c2dbb5edf15fcbcacef2c82a2048fcb3f8
parentdd2a0d33614a6a838b1473bf05202ee271127430 (diff)
downloadorg-mode-c6f9aeb06ea9a5ae4d19218a514e28b294d5cbf6.tar.gz
ox-publish: Fix too many opened buffer upon publishing
* lisp/ox-publish.el (org-publish-cache-file-needs-publishing): Create a new buffer for Org files only. Reported-by: Éric Würbel <eric.wurbel@univ-amu.fr> <http://permalink.gmane.org/gmane.emacs.orgmode/110190>
-rw-r--r--lisp/ox-publish.el57
1 files changed, 28 insertions, 29 deletions
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 2dabcd9..e8271f6 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -1199,39 +1199,38 @@ the file including them will be republished as well."
(unless org-publish-cache
(error
"`org-publish-cache-file-needs-publishing' called, but no cache present"))
- (let* ((case-fold-search t)
- (key (org-publish-timestamp-filename filename pub-dir pub-func))
+ (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
(pstamp (org-publish-cache-get key))
(org-inhibit-startup t)
- (visiting (find-buffer-visiting filename))
- (buf (find-file-noselect (expand-file-name filename)))
included-files-ctime)
(when (equal (file-name-extension filename) "org")
- (unwind-protect
- (with-current-buffer buf
- (goto-char (point-min))
- (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t)
- (let* ((element (org-element-at-point))
- (included-file
- (and (eq (org-element-type element) 'keyword)
- (let ((value (org-element-property :value element)))
- (and value
- (string-match
- "\\`\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)"
- value)
- (let ((m (match-string 1 value)))
- (org-unbracket-string
- "\"" "\""
- ;; Ignore search suffix.
- (if (string-match "\\(::\\(.*?\\)\\)\"?\\'"
- m)
- (substring m 0 (match-beginning 0))
- m))))))))
- (when included-file
- (push (org-publish-cache-ctime-of-src
- (expand-file-name included-file))
- included-files-ctime)))))
- (unless visiting (kill-buffer buf))))
+ (let ((visiting (find-buffer-visiting filename))
+ (buf (find-file-noselect filename))
+ (case-fold-search t))
+ (unwind-protect
+ (with-current-buffer buf
+ (goto-char (point-min))
+ (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t)
+ (let* ((element (org-element-at-point))
+ (included-file
+ (and (eq (org-element-type element) 'keyword)
+ (let ((value (org-element-property :value element)))
+ (and value
+ (string-match
+ "\\`\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)"
+ value)
+ (let ((m (match-string 1 value)))
+ (org-unbracket-string
+ "\"" "\""
+ ;; Ignore search suffix.
+ (if (string-match "::.*?\"?\\'" m)
+ (substring m 0 (match-beginning 0))
+ m))))))))
+ (when included-file
+ (push (org-publish-cache-ctime-of-src
+ (expand-file-name included-file))
+ included-files-ctime)))))
+ (unless visiting (kill-buffer buf)))))
(or (null pstamp)
(let ((ctime (org-publish-cache-ctime-of-src filename)))
(or (< pstamp ctime)