summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-10-29 11:31:19 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-10-29 11:31:19 +0100
commita8c026cb26b7e2ed27d52e1637c3e219e163ec94 (patch)
treef83ba3c01eb1def84683c392c65658b049c207ad
parent99110c60a6c732f6e9131de7ac6090e19e1d01eb (diff)
downloadorg-mode-a8c026cb26b7e2ed27d52e1637c3e219e163ec94.tar.gz
org-export: Explicit error when using invalid syntax for INCLUDE keywords
* contrib/lisp/org-export.el (org-export-expand-include-keyword): Error out when file isn't specified within double quotes. * testing/lisp/test-org-export.el: Add test.
-rw-r--r--contrib/lisp/org-export.el3
-rw-r--r--testing/lisp/test-org-export.el4
2 files changed, 6 insertions, 1 deletions
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el
index 134f1d0..647518b 100644
--- a/contrib/lisp/org-export.el
+++ b/contrib/lisp/org-export.el
@@ -2771,7 +2771,7 @@ working directory. It is used to properly resolve relative
paths."
(let ((case-fold-search t))
(goto-char (point-min))
- (while (re-search-forward "^[ \t]*#\\+INCLUDE: \\(.*\\)" nil t)
+ (while (re-search-forward "^[ \t]*#\\+INCLUDE: +\\(.*\\)[ \t]*$" nil t)
(when (eq (org-element-type (save-match-data (org-element-at-point)))
'keyword)
(beginning-of-line)
@@ -2803,6 +2803,7 @@ paths."
;; Remove keyword.
(delete-region (point) (progn (forward-line) (point)))
(cond
+ ((not file) (error "Invalid syntax in INCLUDE keyword"))
((not (file-readable-p file)) (error "Cannot include file %s" file))
;; Check if files has already been parsed. Look after
;; inclusion lines too, as different parts of the same file
diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el
index 74a580d..8b9f319 100644
--- a/testing/lisp/test-org-export.el
+++ b/testing/lisp/test-org-export.el
@@ -386,6 +386,10 @@ text
(ert-deftest test-org-export/expand-include ()
"Test file inclusion in an Org buffer."
+ ;; Error when file isn't specified.
+ (should-error
+ (org-test-with-temp-text "#+INCLUDE: dummy.org"
+ (org-export-expand-include-keyword)))
;; Full insertion with recursive inclusion.
(org-test-with-temp-text
(format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir)