summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-07-06 23:55:48 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-07-06 23:55:48 +0200
commitbaa2c5943a4afce71a6336cbd957139e840bd952 (patch)
treea5d0b30b1f6313f44427288b664b92af5b1c83de
parent4235718d7901a243086288bdae32475b558ec1ce (diff)
downloadorg-mode-baa2c5943a4afce71a6336cbd957139e840bd952.tar.gz
org-element: Avoid using a slow regexp
* lisp/org-element.el (org-element-latex-fragment-parser): Avoid using a slow regexp.
-rw-r--r--lisp/org-element.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index f5208d4..7aa8208 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -2916,8 +2916,11 @@ Assume point is at the beginning of the LaTeX fragment."
(if (eq (char-after (1+ (point))) ?$)
(search-forward "$$" nil t 2)
(and (not (eq (char-before) ?$))
- (looking-at "\\$[^ \t\n,;.$]\\(?:[^$]*?[^ \t\n,.$]\\)?\\$\\([- \t.,?;:'\")]\\|$\\)")
- (match-beginning 1)))
+ (search-forward "$" nil t 2)
+ (not (memq (char-before (match-beginning 0))
+ '(?\s ?\t ?\n ?, ?.)))
+ (looking-at "\\([- \t.,?;:'\"]\\|$\\)")
+ (point)))
(case (char-after (1+ (point)))
(?\( (search-forward "\\)" nil t))
(?\[ (search-forward "\\]" nil t))