Fix fontification of LaTeX elements (take two)

* lisp/org.el (org-do-latex-and-related): Fix last commit.
This commit is contained in:
Nicolas Goaziou 2018-12-16 11:08:00 +01:00
parent dc74770706
commit af3e2b1856
1 changed files with 28 additions and 32 deletions

View File

@ -6260,13 +6260,12 @@ done, nil otherwise."
(when (org-string-nw-p org-latex-and-related-regexp) (when (org-string-nw-p org-latex-and-related-regexp)
(catch 'found (catch 'found
(while (re-search-forward org-latex-and-related-regexp limit t) (while (re-search-forward org-latex-and-related-regexp limit t)
(unless (cl-some (unless (cl-some (lambda (f) (memq f '(org-code org-verbatim underline
(lambda (f) (memq f '(org-code org-verbatim underline
org-special-keyword))) org-special-keyword)))
(save-excursion (save-excursion
(goto-char (1+ (match-beginning 0))) (goto-char (1+ (match-beginning 0)))
(face-at-point nil t))) (face-at-point nil t)))
(let* ((start (if (memq (char-after (1+ (match-beginning 0))) (let ((start (if (memq (char-after (1+ (match-beginning 0)))
'(?_ ?^)) '(?_ ?^))
(1+ (match-beginning 0)) (1+ (match-beginning 0))
(match-beginning 0))) (match-beginning 0)))
@ -6275,21 +6274,18 @@ done, nil otherwise."
(e (match-end 0)) (e (match-end 0))
(m (buffer-substring-no-properties b e))) (m (buffer-substring-no-properties b e)))
(cond (cond
((string-match "\\`[ \t]*\\\\begin{\\([a-zA-Z0-9\\*]+\\)}" ((string-match "\\`[ \t]*\\\\begin{\\([a-zA-Z0-9\\*]+\\)}" m)
m) (let ((re (format "\\\\end{%s}[ \t]*$"
(let ((closing
(format "\\\\end{%s}[ \t]*$"
(regexp-quote (match-string 1 m))))) (regexp-quote (match-string 1 m)))))
(or (re-search-forward closing nil t) e))) (or (re-search-forward re nil t) e)))
((string-match "\\\\end{\\([a-zA-Z0-9\\*]+\\)}[ \t]*\\'" m) ((string-match "\\\\end{\\([a-zA-Z0-9\\*]+\\)}[ \t]*\\'" m)
(let ((opening (let ((re (format "^[ \t]*\\\\begin{%s}"
(format "^[ \t]*\\\\begin{%s}"
(regexp-quote (match-string 1 m))))) (regexp-quote (match-string 1 m)))))
(setq start (or (save-excursion (setq start
(re-search-backward opening nil t)) (or (save-excursion (re-search-backward re nil t))
b)) b))
(line-end-position))) (line-end-position)))
((string-match "\\\\[a-zA-Z]+\\*?{" m) ((string-match "\\`\\\\[a-zA-Z]+\\*?{\\'" m)
(search-forward "}" nil t)) (search-forward "}" nil t))
(t e))))) (t e)))))
(font-lock-prepend-text-property (font-lock-prepend-text-property