How to get background type of Emacs? e.g. 'light
or 'dark
You can define a face like this:
(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 select correct font face automatically by current background type. But I want to know how it do. (It is better if there is an build-in function in Emacs)
By the way, I try to seek in source code and found a function (frame-background-color), but its output is string like "#ffffff".
You can use the function frame-parameter
to get the attributes of a frame. For your particular case you can do
(frame-parameter nil 'background-mode)
To get background-mode of the current frame. The first parameter is the frame for which you want to the get specified parameter, if nil the currently selected frame is used. You can do C-hfframe-parameter
RET