summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-12-16 11:08:00 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-12-16 11:08:00 +0100
commitaf3e2b1856be4088071bd01f386560cff1e292bc (patch)
treebe1a99c7ecc35e845d2aa0305fa5d07375acad9d
parentdc7477070616d01f4da2b60692e72de85bfcc7b4 (diff)
downloadorg-mode-af3e2b1856be4088071bd01f386560cff1e292bc.tar.gz
Fix fontification of LaTeX elements (take two)
* lisp/org.el (org-do-latex-and-related): Fix last commit.
-rw-r--r--lisp/org.el60
1 files changed, 28 insertions, 32 deletions
diff --git a/lisp/org.el b/lisp/org.el
index c62b448..64d7fed 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6260,38 +6260,34 @@ done, nil otherwise."
(when (org-string-nw-p org-latex-and-related-regexp)
(catch 'found
(while (re-search-forward org-latex-and-related-regexp limit t)
- (unless (cl-some
- (lambda (f) (memq f '(org-code org-verbatim underline
- org-special-keyword)))
- (save-excursion
- (goto-char (1+ (match-beginning 0)))
- (face-at-point nil t)))
- (let* ((start (if (memq (char-after (1+ (match-beginning 0)))
- '(?_ ?^))
- (1+ (match-beginning 0))
- (match-beginning 0)))
- (end
- (let* ((b (match-beginning 0))
- (e (match-end 0))
- (m (buffer-substring-no-properties b e)))
- (cond
- ((string-match "\\`[ \t]*\\\\begin{\\([a-zA-Z0-9\\*]+\\)}"
- m)
- (let ((closing
- (format "\\\\end{%s}[ \t]*$"
- (regexp-quote (match-string 1 m)))))
- (or (re-search-forward closing nil t) e)))
- ((string-match "\\\\end{\\([a-zA-Z0-9\\*]+\\)}[ \t]*\\'" m)
- (let ((opening
- (format "^[ \t]*\\\\begin{%s}"
- (regexp-quote (match-string 1 m)))))
- (setq start (or (save-excursion
- (re-search-backward opening nil t))
- b))
- (line-end-position)))
- ((string-match "\\\\[a-zA-Z]+\\*?{" m)
- (search-forward "}" nil t))
- (t e)))))
+ (unless (cl-some (lambda (f) (memq f '(org-code org-verbatim underline
+ org-special-keyword)))
+ (save-excursion
+ (goto-char (1+ (match-beginning 0)))
+ (face-at-point nil t)))
+ (let ((start (if (memq (char-after (1+ (match-beginning 0)))
+ '(?_ ?^))
+ (1+ (match-beginning 0))
+ (match-beginning 0)))
+ (end
+ (let* ((b (match-beginning 0))
+ (e (match-end 0))
+ (m (buffer-substring-no-properties b e)))
+ (cond
+ ((string-match "\\`[ \t]*\\\\begin{\\([a-zA-Z0-9\\*]+\\)}" m)
+ (let ((re (format "\\\\end{%s}[ \t]*$"
+ (regexp-quote (match-string 1 m)))))
+ (or (re-search-forward re nil t) e)))
+ ((string-match "\\\\end{\\([a-zA-Z0-9\\*]+\\)}[ \t]*\\'" m)
+ (let ((re (format "^[ \t]*\\\\begin{%s}"
+ (regexp-quote (match-string 1 m)))))
+ (setq start
+ (or (save-excursion (re-search-backward re nil t))
+ b))
+ (line-end-position)))
+ ((string-match "\\`\\\\[a-zA-Z]+\\*?{\\'" m)
+ (search-forward "}" nil t))
+ (t e)))))
(font-lock-prepend-text-property
start end 'face 'org-latex-and-related)
(add-text-properties start end '(font-lock-multiline t)))