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)))
)
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
hi: Each time I insert some text in emacs , it will highlight the newly added text. I wonder how to change the background color of the highlight, because the highlight background color is very close to the font color , as a result, I can hardly recognize the code that I am writing.
thank you soooo much
For issues with fonts (which Emacs calls faces) inside of Emacs, it is often helpfull to know the function 'list-faces-display'. You can call this with M-x and it will list all faces defined in the current frame. This can be helpfull both identifying which face is problematic, it will also give you its name which can be used to modify the face. For instance to change the foreground colour of the face named "button" you can call something like this:
(set-face-foreground 'button "cyan")
The effect will be immediately visible. Many aspects of faces can be changed, including colour, font familiy and font size.
Obviously, this will not help you if the problematic behaviour stems from the terminal emulator you are using, as it would appear from some of the comments to your question, then the problem is outside of Emacs and cannot be fixed from inside of Emacs. Even so, knowing about 'list-faces-display' is usefull.
I had this exact question and managed to solve it using the following ways. But I also had another thing in mind: a marker to show which lines are modified.
For tracking changes between the saved file and the buffer, we should use the highlight-changes-mode. But before enabling that mode, we need to prepare some stuff as explained beautifully here for the line marks:
;; a part to add the fringe marks to the gutter. To change the shape, read the explanation of it in this code.
(eval-after-load "hilit-chg"
'(progn
(defvar highlight-fringe-mark 'filled-square
"The fringe bitmap name marked at changed line.
Should be selected from `fringe-bitmaps'.")
(defadvice hilit-chg-make-ov (after hilit-chg-add-fringe activate)
(mapc (lambda (ov)
(if (overlay-get ov 'hilit-chg)
(let ((fringe-anchor (make-string 1 ?x)))
(put-text-property 0 1 'display
(list 'left-fringe highlight-fringe-mark)
fringe-anchor)
(overlay-put ov 'before-string fringe-anchor))
))
(overlays-at (ad-get-arg 1))))))
;; make the highlight-changes-mode reset when the file is saved
(add-hook 'local-write-file-hooks 'highlight-changes-rotate-faces)
(add-hook 'after-save-hook
(lambda ()
(when highlight-changes-mode
(save-restriction
(widen)
(highlight-changes-remove-highlight (point-min) (point-max))))))
make sure it is enabled globally except for buffers that start with ' and *
(setq highlight-changes-global-modes t)
(global-highlight-changes-mode)
make the mode to respect the syntax-highlighting
;; find the name of other faced using M-x ~list-faces-display~
(custom-set-faces
'(highlight-changes ((t (:background "dark green" :foreground nil)))))
(set-face-foreground 'highlight-changes nil)
(set-face-background 'highlight-changes "dark green")
I'd like to have emacs not to have a background color when I open a frame in the terminal. I'm using a terminal with a translucent background, and characters with a background color are not "see-through". TERM is set to "xterm-256color".
How do I get emacs to use the default background color (no color at all), when the frame is not graphical?
Edit:
I've got it, sort of:
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'my-awesome-theme t)
(defun on-frame-open (frame)
(if (not (display-graphic-p frame))
(set-face-background 'default "unspecified-bg" frame)))
(on-frame-open (selected-frame))
(add-hook 'after-make-frame-functions 'on-frame-open)
I put the above code in my init file, but only suppresses the background when opening an emacsclient in a terminal, and not emacs itself (i.e. only when invoked with emacsclient -t and not when invoked with emacs). Adding an extra (unless window-system (set-face-background 'default "unspecified-bg" (selected-frame))) doesn't work and only confuses graphical frames.
Any ideas on why this might happen?
(defun on-after-init ()
(unless (display-graphic-p (selected-frame))
(set-face-background 'default "unspecified-bg" (selected-frame))))
(add-hook 'window-setup-hook 'on-after-init)
Combined with the code in your edit, it worked nicely for me for both emacsterms and newly started emacsen. As for why window-setup-hook:
http://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html
(neither of the earlier hooks seemed to work except for this one.)
I tried the method that was suggested in this answer but I had no luck getting it to work. this snippet works for me though
(defun on-frame-open (&optional frame)
"If the FRAME created in terminal don't load background color."
(unless (display-graphic-p frame)
(set-face-background 'default "unspecified-bg" frame)))
(add-hook 'after-make-frame-functions 'on-frame-open)
Although it has a setback, if the terminal has a different background settings than the theme I use (dark vs. light), default theme faces are being used which may not seem good on the light or dark background. but in my case which both terminal and theme are dark it works fine.
There are already two answers to this question, one using window-setup-hook, which is called on startup, and another using after-make-frame-functions, which is called when a new frame is made, including after invoking emacsclient. To cover all possible cases, I found that I needed to do it this way:
(defun set-background-for-terminal (&optional frame)
(or frame (setq frame (selected-frame)))
"unsets the background color in terminal mode"
(unless (display-graphic-p frame)
(set-face-background 'default "unspecified-bg" frame)))
(add-hook 'after-make-frame-functions 'set-background-for-terminal)
(add-hook 'window-setup-hook 'set-background-for-terminal)
Note that I am only using selected-frame if necessary; it seems that in client mode, the hook is called before the frame is selected, so it is important to use the frame argument in that case.
I have an issue using Emacs 24.1.1 on Mac OS X. I'm editing Jade and CoffeeScript files, so I've turned on whitespace-mode for those file types.
What I'm seeing is that lines longer than 70 characters are highlighted with the whitespace-line font face, regardless of the setting of whitespace-line-column.
In this shot, it is clear that I've customized whitespace-line-column to track fill-column, and I've set fill-column to 120, but much shorter lines are being highlighted.
I've glanced over the code for the Jade mode and don't see anything that would explain the behavior, but I have only a passing understanding of Emacs Lisp.
Thanks in advance for any pointers!
You have to set whitespace-line-column before you activate whitespace-mode. That is, if you want to change its value it does not take effect unless you turn whitespace-mode off and on again. Ironically, that variable is not available for M-x customize until you have activated the mode once :-(
However, you can customize the global value of this variable by putting the following line in your .emacs file:
(setq whitespace-line-column 120)
Since your .emacs is evaluated when you start Emacs, the setting will take effect before you invoke whitespace-mode for the first time and should thus do what you want. If you don't want to set the value globally, but only for Jade files, put the following in your .emacs file instead:
(set (make-local-variable 'whitespace-line-column) 80)
(add-hook 'after-change-major-mode-hook
'(lambda () (when (eq major-mode 'jade-mode)
(setq whitespace-line-column 120))))
If you never want long lines to be highlighted specially at all, there is a third option you might want to consider. You could customize the variable whitespace-style (by typing M-x customize-variable ENTER whitespace-style ENTER) and in the value list remove the entries:
lines
lines-tail
(if any). This should turn off highlighting of long lines globally independent of the value of whitespace-line-column (again, only after you de- and re-activate whitespace mode).
My .emacs file is here. I want the theme to change when I am in shell-mode. But what happens is that the theme gets applied to all the windows. I set the variable color-theme-is-global to nil, but the problem still persists.
(add-hook 'shell-mode-hook 'color-theme-monokai-terminal)
(set-variable 'color-theme-is-global nil)
These are the corresponding lines in my .emacs file. What should I do to make it work?
I usually start Emacs as a daemon and then open frames as needed. I use different color themes for X frames and terminal frames like so:
(require 'color-theme)
(color-theme-initialize)
(defun apply-color-theme (frame)
"Apply color theme to a frame based on whether its a 'real'
window or a console window."
(select-frame frame)
(if (window-system frame)
(color-theme-tango)
(color-theme-tango-black)))
(setq color-theme-is-global nil)
(add-hook 'after-make-frame-functions 'apply-color-theme)
You can replace the (if window-system ...) part with your check for shell-script-mode and the color-theme-X parts with your favorite themes.
There is one downside to this: if you don't start Emacs as a deamon, the customization will only kick in after you create a second frame, the first one that pops up will have the standard theme.
I think your terminology is off: in emacs-speak frame means what people normally mean by window in a graphical environment. (That is, the thing that has the close, minimize and maximize buttons and a titlebar, etc, is the "frame".) Whereas the things that show up when you do a C-x 3 (split-window) are called windows, and when you do something like M-x shell-mode you get a new buffer, which may or may not be in a new window.
Color themes are always frame-global (as far as I know, and it's certainly what the documentation suggests) the variable color-theme-is-global determines whether a single theme propagates across frames.
I'm thinking that the closest thing to what you want is something like (completely untested, probably broken):
(defun shell-mode-in-new-frame ()
(interactive)
(select-frame (make-frame))
(color-theme-monokai-terminal)
(shell-mode))
Although this does create a new frame, which isn't what you want.