emacs equivalent of vim's bg=dark? (setting background to dark)
In vim, I can run set 开发者_高级运维bg=dark
and then vim will adjust all syntax highlighting to work on a terminal with a dark background (whether or not the background actually is dark, vim will assume that it is).
How do I tell emacs to assume that the background is either dark or light?
I've used the invert-face
function in the past:
(invert-face 'default)
Or:
M-x invert-face <RET> default
I think the best approach to use is to use ColorTheme. Other options to customize the frame colors you can find here. I can't think about a single command, however you can start emacs with --reverse-video
.
M-x set-variable <RET> frame-background-mode <RET> dark
see also the bottom of https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Faces.html
Write this at the end of your ~/.emacs
file :
;; dark mode
(when (display-graphic-p)
(invert-face 'default)
)
(set-variable 'frame-background-mode 'dark)
Note: The "when" sentence is there to avoid to invert colors in no-window mode (I presume your terminal has already a black background).
The alect-themes package for Emacs 24 provides light, dark, and black themes, and can be installed either manually or using MELPA.
To install alect-themes
using MELPA and select alect-dark
(from ~/emacs.d/init.d
):
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://melpa-stable.milkbox.net/packages/"))
(package-initialize)
(load-theme 'alect-dark)
)
There are quite a few color theme packages in MELPA, so if alect-themes doesn't meet your needs, experiment with some of the others.
精彩评论