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.
Related
I installed Emacs and want to get the atom.io theme, like here:
GitHub
The colors should be:
And now here is a Screenshot how my colors are looking:
I also have atom.io installed and the Preview of the sample is correct. Here is my atom.io screenshot:
Finally, my .emacs config file:
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
(load-theme 'atom-one-dark t)
(require 'powerline)
(powerline-default-theme)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("90d329edc17c6f4e43dbc67709067ccd6c0a3caa355f305de2041755986548f2" "b9c57187960682d4$
'(desktop-save-mode 1)
'(global-hl-line-mode 1)
'(global-linum-mode 1))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
Why are the colors different at my Emacs?
Can this be cause i have the wrong color setup? or why could it be wrong?
I ran into the same issue, it seems to be a common for Mac users.
I found some help on the issues section on the GitHub page of a similar theme, dracula. I followed apierz's fixes to correct the colors on my terminal.
From comparing the dracula theme code with the atom one theme, you can see that both themes use a background of hex color #282*. Basically we need to change the hex color of the background to something more compatible.
Comment out this line of code in your atom-one-theme.el file, and add another one with a color value of nil.
;;; Code:
(deftheme atom-one-dark
"Atom One Dark - An Emacs port of the Atom One Dark theme from Atom.io.")
(defvar atom-one-dark-colors-alist
'(("atom-one-dark-accent" . "#528BFF")
("atom-one-dark-fg" . "#ABB2BF")
;; ("atom-one-dark-bg" . "#282C34")
("atom-one-dark-bg" . nil
This should make your background the same color as your terminal window. Since I have a similar background color to #282C34, mine ends up looking a lot like Atom One Dark Theme.
Alternatively, you can set the background color to #000000 (black), however I didn't find it to look too attractive.
Shoutout to apierz for originally posting the fix on GitHub!
what_it_should_look_like.png
mode is here : http://emacswiki.org/emacs/AutoComplete
and in the bottom:
I have a black background and when I use auto-complete, as soon as I
type something my cursor turns black, so now I can’t see it. Help! How
am I going to fix this problem?
Ok nevermind, fixed it. Just added (set-cursor-color “white”) to my
.emacs file after loading the auto-complete package.
So I just made it too. even (set-cursor-color “#ffffff”) but it doesn't help me. How can I solve this problem?
Correction: it works for emacs but doesn't work for emacsclient
Maybe I must to add some hook? But I need to make a proper hook then, not to add all my mess where I'm trying to solve the trouble setting everything foreground light background dark...
also here is off-topic question: why most of professional emacs users use light themes?
config:
(require 'auto-complete-config)
(ac-config-default)
(set-face-background 'ac-completion-face "darkgray")
(set-face-underline 'ac-completion-face "lightgray")
(set-face-background 'ac-yasnippet-candidate-face "black")
(set-face-underline 'ac-yasnippet-candidate-face "sandybrown")
(set-face-background 'ac-candidate-face "darkgray")
(set-face-underline 'ac-candidate-face "lightgray")
(set-face-background 'ac-selection-face "steelblue")
(set-cursor-color "#ffffff")
(provide 'auto-complete-settings)
Answers for comments:
(frame-parameter (selected-frame) 'cursor-color)
"black"
-- before autocomplete (when cursor light) and after when cursor goes dark.
The three faces which autocomplete uses are ac-candidate-face, ac-completion-face and ac-selection-face. Customising them should take care of your problem.
I'm not using autocomplete, but I can't reproduce this behaviour for the default face.
In 23.1.1 I can set the background colour of the default face using the same function you've specified, and it applies the change and sets it as the default value for all subsequent frames, including those from emacsclients.
Can you confirm that you're definitely talking to a server to which your changes have been made?
Here is what works for me:
(defun frame-bg (frame)
"Custom behaviours for new frames."
(with-selected-frame frame
(set-cursor-color "#ffffff")
))
(frame-bg (selected-frame))
(add-hook 'after-make-frame-functions 'frame-bg)
I agree that Heather's answer will work, but I found that all I needed to solve this problem was to put the following into my .emacs file (after enabling auto-complete-mode):
(set-cursor-color “white”)
I have the following code in my .emacs:
(if (null window-system)
(progn
(require 'color-theme)
(color-theme-initialize)
(color-theme-simple-1)))
When I open Emacs on the console, I can verify that the progn block runs (by a (message "Got here.")), and I see a flash that suggests that the color theme was loaded, but if it was loaded, it is overridden by something else. If, after loading, I open my .emacs file and submit the block above using C-x C-e, it works. I've tried doing:
(add-hook 'after-init-hook
(lambda ()
(progn
(require 'color-theme)
(color-theme-initialize)
(color-theme-simple-1))))
but that acts the same.
It may be relevant that I'm using Emacs 24, and that this code is not in my .emacs, but in ~/Dropbox/.emacs, which is loaded from my .emacs.
An additional note: I've tried M-x customize-themes, but none of those work acceptably on the console. They either produce a nearly unreadable light theme, or most of the text is invisible.
Emacs 24 has built-in theming, which doesn't use statements like (require 'color-theme). As Drew points out in the comments, there are differences between color themes and custom themes, and the new direction is towards the latter. Try M-x customize-themes to take a look. From .emacs, you can do things like (load-theme 'wombat t).
But...
It may still be going wrong for you. One thing that can mess it up like this is changing the face -- maybe in the custom-set-faces part of your .emacs file. Emacs's interactive customization automatically includes the color information (both background and foreground) of whatever theme you happen to be using at the time you set it, so this can definitely make trouble with color themes. If that is what's causing it, you can just set the particular attribute you care about with something like
(set-face-attribute 'default nil :height 120)
That will change the font size without changing the colors.
Emacs 24 have own theming system.
M-x customize-themes
or
(custom-set-variables
....
'(custom-enabled-themes (quote (selected-theme)))
)
since I can't get CEDET to work for automatic code-completion (aka intelli-sense in the MS-world), after trying several times (no, it's just not working!), I've decided to use auto-complete, which works "quite fine" for me.
Unfortunately, auto-complete has an annoying behaviour when it comes to quit the imenu with its suggestions.
auto-complete starts imenu, no matter how many suggestions it has. So, if there's only one suggestion, the menu appears.
1.
To exit the imenu, I have to use the LEFT or RIGHT keys in order to make the menu disappear. ESC-ESC-ESC does not have any effect.
Is there any way, to modify these two behaviors?
Here's an excerpt of my .emacs file showing the auto-complete relevant stuff:
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(setq ac-delay 0.5) ;; eclipse uses 500ms
Kind regards,
mefiX
'Stop autocompleting' can be set by adding the following to your .emacs:
(define-key ac-completing-map "\ESC/" 'ac-stop)
...or alternatively you can use C-g as the default Emacs StopSomething command :)
As for showing the completion in a menu when there's only one candidate, I'm not really sure what other behaviour you'd want?
Does anyone know if I can find an emacs color syntax configuration which resembles eclipse's syntax coloring? Thank you for any suggestion.
I'm not sure what Eclipse looks like, but you might want to check out Color Theme There are lots of color themes included with it and you can easily create you own if you don't like any you see.
I think you want font-lock. The emacs name for syntax coloring. I get it with the mode (Java mode, C# mode, cc-mode, etc).
I have in my .emacs:
;; for fontification in emacs progmodes:
(load "font-lock")
(setq font-lock-maximum-decoration t)
;; turn on font-lock globally
(global-font-lock-mode 1 'ON)
And then it just works, for all the various prog modes.
Emacs with C# http://www.freeimagehosting.net/uploads/6be39f23a3.jpg
Try this... http://jasonm23.github.com/emacs-theme-editor/
It will customize most of the standard font-lock parameters (keywords, functions, constants, vars, etc....)
You can paste in an existing theme and edit it, if you have something almost right.
There's a few samples on http://jasonm23.github.com
You might also like the code theme generator at http://inspiration.sweyla.com/code/
I use the same .xemacs/init.el file for both Emacs and Xemacs.
In order for it to work, I use the following:
; turn on faces
(font-lock-mode 1)
;; Turn on font-lock mode for Emacs
(cond ((not running-xemacs)
(global-font-lock-mode t)
))
Also you might need to add modes for various files. For example:
(setq auto-mode-alist (mapcar 'purecopy
'(("\\.c$" . c-mode)
("\\.cc$" . c-mode)
("\\.cxx$" . c++-mode)
("\\.htm$" . html-mode)
("\\.java$" . java-mode))))
Note there is also a Go mode for emacs which supports color highlighting. URL for Go-mode for Emacs