forked from mirrors/org-mode
org: Update LaTeX overlay during fontification
* lisp/org.el (org-do-latex-and-related, org-latex-preview-options): To ensure that LaTeX preview overlays update as the face changes (for instance, when in a heading that changes level), the face used is updated during fontification when applicable. This also ensures that the correct face is used when JIT fontification is active.
This commit is contained in:
parent
febabadb99
commit
0d28e6ef72
14
lisp/org.el
14
lisp/org.el
|
@ -5529,6 +5529,9 @@ Result depends on variable `org-highlight-latex-and-related'."
|
|||
(append re-latex re-entities re-sub)
|
||||
"\\|"))))
|
||||
|
||||
(defvar org-latex-preview-options) ; Defined in org-latex-preview.el.
|
||||
(declare-function org-latex-preview--face-around "org-latex-preview" (start end))
|
||||
|
||||
(defun org-do-latex-and-related (limit)
|
||||
"Highlight LaTeX snippets and environments, entities and sub/superscript.
|
||||
Stop at first highlighted object, if any. Return t if some
|
||||
|
@ -5569,6 +5572,17 @@ highlighting was done, nil otherwise."
|
|||
'face 'org-latex-and-related))
|
||||
(add-text-properties (+ offset (match-beginning 0)) (match-end 0)
|
||||
'(font-lock-multiline t))
|
||||
;; Refresh the face of LaTeX previews (when applicable).
|
||||
(when (eq (plist-get org-latex-preview-options :foreground)
|
||||
'auto)
|
||||
(dolist (ov (overlays-at start))
|
||||
(when (and (eq (overlay-get ov 'org-overlay-type)
|
||||
'org-latex-overlay)
|
||||
(overlay-get ov 'face)
|
||||
(not (eq (overlay-get ov 'face) 'error)))
|
||||
(overlay-put ov 'face
|
||||
(org-latex-preview--face-around
|
||||
(overlay-start ov) (overlay-end ov))))))
|
||||
(throw 'found t)))))
|
||||
nil))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue