How to get Emacs background type? e.g. light or dark

How to get Emacs background type? for example 'lightor'dark

You can define a face as follows:

(defface moedict-type
  '((((class color) (background light))
     (:foreground "#ffffd7" :background "#525252"))
    (((class color) (background dark))
     (:foreground "#525252" :background "#c1c1c1")))
  "Face for type. ex: [ε‹•]、[名]")

And Emacs will automatically select the correct font surface for the current background type. But I want to know how this happens. (Better if Emacs has a built-in function)

By the way, I try to search in the source code and find a function (frame-background-color), but its output has a string like "#ffffff".

+7
source share
2 answers

You can use the function frame-parameterto get the attributes of the frame. For your specific case you can do

(frame-parameter nil 'background-mode)

. , , . C-h f frame-parameter RET

+6

defface, , class, background, min-colors .

0

Source: https://habr.com/ru/post/1527347/


All Articles