summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-08-24 12:15:53 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-08-24 12:58:42 +0200
commit4bc4e8ec1850c29a172f1f7dda4d553d826f0fdd (patch)
tree1b42be1e7475510ea81e0dee2fd82a5f651bd4c9
parent10dbdf5fc28f0346f00e753792553c6d7244457e (diff)
downloadorg-mode-4bc4e8ec1850c29a172f1f7dda4d553d826f0fdd.tar.gz
org-element: Paragraphs don't end at incomplete latex environments
* lisp/org-element.el (org-element-paragraph-separate): Since this variable is meant to be searched forward, \end{...} shouldn't trigger the end of a paragraph before checking if it is the end of a complete environment. (org-element-latex-environment-parser): Slight change to the regexp matching the beginning of a latex environment. (org-element-paragraph-parser): Paragraphs don't end at incomplete latex environments. (org-element-latex-or-entity-successor): Remove paragraph environments from latex fragment search.
-rw-r--r--lisp/org-element.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 3bf217d..f0e1a0f 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -140,7 +140,7 @@
;; Horizontal rules.
"-\\{5,\\}[ \t]*$" "\\|"
;; LaTeX environments.
- "\\\\\\(begin\\|end\\)" "\\|"
+ "\\\\begin{\\([A-Za-z0-9]+\\*?\\)}" "\\|"
;; Planning and Clock lines.
(regexp-opt (list org-scheduled-string
org-deadline-string
@@ -1700,7 +1700,7 @@ Assume point is at the beginning of the latex environment."
(code-begin (point))
(keywords (org-element--collect-affiliated-keywords))
(begin (car keywords))
- (env (progn (looking-at "^[ \t]*\\\\begin{\\([A-Za-z0-9*]+\\)}")
+ (env (progn (looking-at "^[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}")
(regexp-quote (match-string 1))))
(code-end
(progn (re-search-forward (format "^[ \t]*\\\\end{%s}" env) limit t)
@@ -1773,6 +1773,15 @@ Assume point is at the beginning of the paragraph."
(concat "^[ \t]*#\\+END_"
(match-string 1))
limit t))))
+ ;; Skip incomplete latex environments.
+ ((save-excursion
+ (beginning-of-line)
+ (looking-at "^[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}"))
+ (not (save-excursion
+ (re-search-forward
+ (format "^[ \t]*\\\\end{%s}"
+ (match-string 1))
+ limit t))))
;; Skip ill-formed keywords.
((not (save-excursion
(beginning-of-line)
@@ -2346,7 +2355,8 @@ LIMIT bounds the search.
Return value is a cons cell whose CAR is `entity' or
`latex-fragment' and CDR is beginning position."
(save-excursion
- (let ((matchers (plist-get org-format-latex-options :matchers))
+ (let ((matchers
+ (remove "begin" (plist-get org-format-latex-options :matchers)))
;; ENTITY-RE matches both LaTeX commands and Org entities.
(entity-re
"\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]]\\)"))