Skip to content

Commit 20e0f1a

Browse files
Get theme information in realtime, don't use variable, otherwise emacs
daemon can't fetch theme foreground/background when it start.
1 parent bb85b10 commit 20e0f1a

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

core/buffer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from PyQt5.QtGui import QKeyEvent, QCursor, QFocusEvent, QBrush, QColor
2424
from PyQt5.QtWidgets import QGraphicsScene, QApplication, qApp
2525
from PyQt5.QtCore import Qt, QEvent, QThread
26-
from core.utils import interactive, abstract, get_clipboard_text, set_clipboard_text, eval_in_emacs, message_to_emacs, input_message, get_emacs_vars, get_emacs_var, get_emacs_func_result
26+
from core.utils import interactive, abstract, get_clipboard_text, set_clipboard_text, eval_in_emacs, message_to_emacs, input_message, get_emacs_vars, get_emacs_var, get_emacs_func_result, get_emacs_theme_mode, get_emacs_theme_foreground, get_emacs_theme_background
2727
import abc
2828
import string
2929
import time
@@ -122,10 +122,9 @@ def __init__(self, buffer_id, url, arguments, fit_to_view):
122122
self.fetch_marker_input_thread = None
123123
self.fetch_search_input_thread = None
124124

125-
(self.theme_background_color, self.theme_foreground_color, self.theme_mode) = get_emacs_vars([
126-
"eaf-emacs-theme-background-color",
127-
"eaf-emacs-theme-foreground-color",
128-
"eaf-emacs-theme-mode"])
125+
self.theme_mode = get_emacs_theme_mode()
126+
self.theme_foreground_color = get_emacs_theme_foreground()
127+
self.theme_background_color = get_emacs_theme_background()
129128

130129
self.enter_fullscreen_request.connect(self.enable_fullscreen)
131130
self.exit_fullscreen_request.connect(self.disable_fullscreen)

core/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ def eval_in_emacs(method_name, args):
233233
# Call eval-in-emacs elisp function.
234234
epc_client.call("eval-in-emacs", args)
235235

236+
def get_emacs_theme_mode():
237+
return get_emacs_func_result("eaf-get-theme-mode", [])
238+
239+
def get_emacs_theme_background():
240+
return get_emacs_func_result("eaf-get-theme-background-color", [])
241+
242+
def get_emacs_theme_foreground():
243+
return get_emacs_func_result("eaf-get-theme-foreground-color", [])
244+
236245
def get_emacs_func_result(method_name, args):
237246
global epc_client
238247

eaf.el

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,26 +1399,6 @@ So multiple EAF buffers visiting the same file do not sync with each other."
13991399
(defun eaf-get-theme-foreground-color ()
14001400
(format "%s" (frame-parameter nil 'foreground-color)))
14011401

1402-
(defcustom eaf-emacs-theme-mode (eaf-get-theme-mode)
1403-
""
1404-
:type 'string)
1405-
1406-
(defcustom eaf-emacs-theme-background-color (eaf-get-theme-background-color)
1407-
""
1408-
:type 'string)
1409-
1410-
(defcustom eaf-emacs-theme-foreground-color (eaf-get-theme-foreground-color)
1411-
""
1412-
:type 'string)
1413-
1414-
(defun eaf-monitor-load-theme (orig-fun &optional arg &rest args)
1415-
"Update `eaf-emacs-theme-mode' after execute `load-theme'."
1416-
(apply orig-fun arg args)
1417-
(setq eaf-emacs-theme-mode (eaf-get-theme-mode))
1418-
(setq eaf-emacs-theme-background-color (eaf-get-theme-background-color))
1419-
(setq eaf-emacs-theme-foreground-color (eaf-get-theme-foreground-color)))
1420-
(advice-add 'load-theme :around #'eaf-monitor-load-theme)
1421-
14221402
(defun eaf--get-current-desktop-name ()
14231403
"Get current desktop name by `wmctrl'."
14241404
(if (string-empty-p eaf-wm-name)

0 commit comments

Comments
 (0)