emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Patch] Update previews correctly with color changes
@ 2021-02-24 21:04 Yuri Lensky
  2021-04-27  7:46 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Yuri Lensky @ 2021-02-24 21:04 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 169 bytes --]

The hash computed for LaTeX previews did not actually take into account the
true foreground/background text color, so org would not refresh previews
when themes change.

[-- Attachment #1.2: Type: text/html, Size: 194 bytes --]

[-- Attachment #2: 0001-lisp-org.el-Update-previews-correctly-when-color-chn.patch --]
[-- Type: application/octet-stream, Size: 2129 bytes --]

From dbecdbb6f3cc5f9b6d094310ecdd6c5aedfe5505 Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <ydl@Yuris-MacBook-Pro.local>
Date: Wed, 24 Feb 2021 12:40:25 -0800
Subject: [PATCH] lisp/org.el: Update previews correctly when color chnages.

* lisp/org.el (org-format-latex): When computing a hash that
determines if a preview needs to be re-generated, use the actual color
of the face rather than just the setting symbol.
---
 lisp/org.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 7d8733448..4ae604fe6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15965,15 +15965,25 @@ Some of the options can be changed using the variable
 			 (fg
 			  (let ((color (plist-get org-format-latex-options
 						  :foreground)))
-			    (if (and forbuffer (eq color 'auto))
-				(face-attribute face :foreground nil 'default)
-			      color)))
+                            (if forbuffer
+                                (cond
+                                 ((eq color 'auto)
+                                  (face-attribute face :foreground nil 'default))
+                                 ((eq color 'default)
+                                  (face-attribute 'default :foreground nil))
+                                 (t color))
+                              color)))
 			 (bg
 			  (let ((color (plist-get org-format-latex-options
 						  :background)))
-			    (if (and forbuffer (eq color 'auto))
-				(face-attribute face :background nil 'default)
-			      color)))
+                            (if forbuffer
+                                (cond
+                                 ((eq color 'auto)
+                                  (face-attribute face :background nil 'default))
+                                 ((eq color 'default)
+                                  (face-attribute 'default :background nil))
+                                 (t color))
+                              color)))
 			 (hash (sha1 (prin1-to-string
 				      (list org-format-latex-header
 					    org-latex-default-packages-alist
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-27  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 21:04 [Patch] Update previews correctly with color changes Yuri Lensky
2021-04-27  7:46 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).