From 10a6b510d7df1298058c0b1c1b6d5b0010f842bf Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 14 Apr 2020 15:34:20 -0400 Subject: [PATCH] Fix background of latex segments in org buffers 'auto doesn't seem to work correctly, especially where face-remap is involved (e.g. with solaire-mode or auto-dim-other-buffers). --- modules/lang/org/config.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index e83b4dc30..7f482b323 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -116,10 +116,20 @@ Is relative to `org-directory', unless it is absolute. Is used in Doom's default ;; Fontify latex blocks and entities, but not natively -- that's too slow (setq org-highlight-latex-and-related '(latex script entities)) - (plist-put! org-format-latex-options - :scale 1.5 ; larger previews - :foreground 'auto ; match the theme foreground - :background 'auto) ; ... and its background + + (plist-put org-format-latex-options :scale 1.5) ; larger previews + (add-hook! 'doom-load-theme-hook + (defun +org-refresh-latex-background-h () + "Previews are rendered with the incorrect background. +This forces it to read the background before rendering." + (plist-put! org-format-latex-options + :background + (face-attribute (if-let (remap (cadr (assq 'default face-remapping-alist))) + (if (keywordp (car-safe remap)) + (plist-get remap :background) + remap) + 'default) + :background nil t)))) ;; HACK Face specs fed directly to `org-todo-keyword-faces' don't respect ;; underlying faces like the `org-todo' face does, so we define our own