Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: disable theme background color in terminal

Tags:

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?

like image 800
Ron Avatar asked Sep 27 '13 15:09

Ron


2 Answers

(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.)

like image 101
Latanius Avatar answered Oct 01 '22 00:10

Latanius


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.

like image 42
Shahab Shahsavari Alavidjeh Avatar answered Oct 01 '22 00:10

Shahab Shahsavari Alavidjeh