From a8f433c31bb3f103875efc7dde8488eea6dece0a Mon Sep 17 00:00:00 2001 From: TEC Date: Tue, 27 Dec 2022 00:14:44 +0800 Subject: [PATCH] org-latex-preview: Get face from char before latex * lisp/org-latex-preview.el (org-create-latex-preview): Instead of getting the face using `face-at-point' use `get-text-property' on the position one before the start of the LaTeX fragment. This ensures that the face is that of the parent element rather than the LaTeX fragment. --- lisp/org-latex-preview.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index b6b0a5694..78c8dda11 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -515,9 +515,9 @@ Some of the options can be changed using the variable (skip-chars-backward " \r\t\n") (point))) (value (org-element-property :value element)) - (face (save-excursion - (goto-char beg) - (face-at-point))) + (face (or (and (> beg 1) + (get-text-property (1- beg) 'face)) + 'default)) (fg (pcase (plist-get org-format-latex-options :foreground) ('auto (face-attribute face :foreground nil 'default)) ('default (face-attribute 'default :foreground nil))