Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2013-05-07 17:49:01 +02:00
commit 29ab1bb74e
1 changed files with 73 additions and 65 deletions

View File

@ -3256,19 +3256,26 @@ working directory. It is used to properly resolve relative
paths." paths."
(let ((case-fold-search t)) (let ((case-fold-search t))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "^[ \t]*#\\+INCLUDE: +\\(.*\\)[ \t]*$" nil t) (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t)
(when (eq (org-element-type (save-match-data (org-element-at-point))) (let ((element (save-match-data (org-element-at-point))))
'keyword) (when (eq (org-element-type element) 'keyword)
(beginning-of-line) (beginning-of-line)
;; Extract arguments from keyword's value. ;; Extract arguments from keyword's value.
(let* ((value (match-string 1)) (let* ((value (org-element-property :value element))
(ind (org-get-indentation)) (ind (org-get-indentation))
(file (and (string-match "^\"\\(\\S-+\\)\"" value) (file (let ((f (if (eq (aref value 0) ?\") (read value)
(prog1 (expand-file-name (match-string 1 value) dir) (and (string-match "^\\S-+" value)
(setq value (replace-match "" nil nil value))))) (match-string 0 value)))))
(setq value
(progn
(string-match (format "^\"?%s\"?[ \t]*" f)
value)
(replace-match "" nil nil value)))
(expand-file-name f dir)))
(lines (lines
(and (string-match (and (string-match
":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\"" value) ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
value)
(prog1 (match-string 1 value) (prog1 (match-string 1 value)
(setq value (replace-match "" nil nil value))))) (setq value (replace-match "" nil nil value)))))
(env (cond ((string-match "\\<example\\>" value) 'example) (env (cond ((string-match "\\<example\\>" value) 'example)
@ -3288,8 +3295,9 @@ paths."
;; Remove keyword. ;; Remove keyword.
(delete-region (point) (progn (forward-line) (point))) (delete-region (point) (progn (forward-line) (point)))
(cond (cond
((not file) (error "Invalid syntax in INCLUDE keyword")) ((not file) nil)
((not (file-readable-p file)) (error "Cannot include file %s" file)) ((not (file-readable-p file))
(error "Cannot include file %s" file))
;; Check if files has already been parsed. Look after ;; Check if files has already been parsed. Look after
;; inclusion lines too, as different parts of the same file ;; inclusion lines too, as different parts of the same file
;; can be included too. ;; can be included too.
@ -3322,7 +3330,7 @@ paths."
(org-export-expand-include-keyword (org-export-expand-include-keyword
(cons (list file lines) included) (cons (list file lines) included)
(file-name-directory file)) (file-name-directory file))
(buffer-string)))))))))))) (buffer-string)))))))))))))
(defun org-export--prepare-file-contents (file &optional lines ind minlevel) (defun org-export--prepare-file-contents (file &optional lines ind minlevel)
"Prepare the contents of FILE for inclusion and return them as a string. "Prepare the contents of FILE for inclusion and return them as a string.