From e1fe7ef4e974251d37eeda58a47f1630b8a5686e Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 10 Aug 2022 21:25:47 +0100 Subject: [PATCH] fix(themes/doom): correctly load theme when running in terminal On macOS when running Emacs in a terminal, the ns-system-appearance variable is defined, but set to nil. We now cater for that, and simply default to loading the dark theme. --- modules/themes/siren-doom-themes.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/themes/siren-doom-themes.el b/modules/themes/siren-doom-themes.el index d43e6b7..c53e3c4 100644 --- a/modules/themes/siren-doom-themes.el +++ b/modules/themes/siren-doom-themes.el @@ -29,12 +29,11 @@ (nlinum-highlight-current-line t) :config - (if (boundp 'ns-system-appearance) - (progn - (siren-doom-themes-set-appearance ns-system-appearance) - (add-hook 'ns-system-appearance-change-functions - 'siren-doom-themes-set-appearance)) - (siren-doom-themes-set-appearance 'dark)) + (if (not (siren-ns-system-appearance)) + (siren-doom-themes-set-appearance 'dark) + (siren-doom-themes-set-appearance ns-system-appearance) + (add-hook 'ns-system-appearance-change-functions + 'siren-doom-themes-set-appearance)) ;; Enable flashing mode-line on errors (doom-themes-visual-bell-config) @@ -46,6 +45,16 @@ (doom-themes-org-config) :preface + (defun siren-ns-system-appearance() + "Return the system appearance, either `dark', `light', or `nil'. + +A return value of `nil' means that the system appearance is could +not be determined. This happens on non-macOS systems, or on macOS +if running Emacs in a terminal." + (if (boundp 'ns-system-appearance) + ns-system-appearance + nil)) + (defgroup siren-doom-themes nil "siren-doom-themes customizations." :group 'doom-themes)