Discussion:
Changing foreground/background colors in all frames
(too old to reply)
Swidan, Firas
2006-06-21 15:33:51 UTC
Permalink
Hi,

I am unable to set the default foreground and background colors in all emacs
frames. I have added

(set-background-color "black")
(set-foreground-color "white")

To my .emacs. This changes the setting in the first emacs frame. However,
if I use

C-x 5 f

To open a new file in a new frame, the foreground/background settings in the
.emacs file do not seem to affect the look of the new frame.

Any ideas how to tackle this issue?

Many thanks and all the best,
Firas.
Gilbert Harman
2006-06-21 17:24:42 UTC
Permalink
Post by Swidan, Firas
I am unable to set the default foreground and background colors in all emacs
frames. I have added
(set-background-color "black")
(set-foreground-color "white")
To my .emacs. This changes the setting in the first emacs frame. However,
if I use
C-x 5 f
To open a new file in a new frame, the foreground/background settings in the
.emacs file do not seem to affect the look of the new frame.
Any ideas how to tackle this issue?
(add-to-list 'default-frame-alist '(foreground-color . "white"))
(add-to-list 'default-frame-alist '(background-color . "black"))


Gil
Ehud Karni
2006-06-21 17:38:38 UTC
Permalink
Post by Swidan, Firas
I am unable to set the default foreground and background colors in all emacs
frames. I have added
(set-background-color "black")
(set-foreground-color "white")
To my .emacs. This changes the setting in the first emacs frame. However,
if I use
C-x 5 f
To open a new file in a new frame, the foreground/background settings in the
.emacs file do not seem to affect the look of the new frame.
The docs for these functions state clearly they change colors only for
the selected frame.

Below is a little function that changes values on all frames (current
and future ones), use it.

Ehud.


(defun set-frame-value-all (key val) ;; change frame attribute
(aput 'initial-frame-alist key val) ;; for ALL frames
(aput 'default-frame-alist key val)
(modify-frame-parameters (selected-frame) (list (cons key val))))


;; instead of (set-background-color "black") use:
(set-frame-value-all 'background-color "black")

;; instead of (set-foreground-color "black") use:
(set-frame-value-all 'foreground-color "black")


--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry
Norbert Melzer
2006-06-21 19:21:55 UTC
Permalink
Post by Ehud Karni
(defun set-frame-value-all (key val) ;; change frame attribute
(aput 'initial-frame-alist key val) ;; for ALL frames
(aput 'default-frame-alist key val)
(modify-frame-parameters (selected-frame) (list (cons key val))))
(set-frame-value-all 'background-color "black")
(set-frame-value-all 'foreground-color "black")
Doesn't help here:

Symbol's function definition is void: aput

Thats what I get when inserting in ~/.emacs and starting :-(
Peter Dyballa
2006-06-21 19:21:27 UTC
Permalink
Post by Swidan, Firas
To open a new file in a new frame, the foreground/background
settings in the
.emacs file do not seem to affect the look of the new frame.
Any ideas how to tackle this issue?
Give these a chance:

(setq initial-frame-alist '(
(mouse-color . "midnightblue")
(foreground-color . "grey20")
(background-color . "alice blue")
(internal-border-width . 2)
(line-spacing . 1)
(top . 20) (left . 650) (width . 91) (height . 60)))
(setq default-frame-alist '(
(border-color . "#4e3832")
(foreground-color . "grey10")
(background-color . "ghost white")
(vertical-scroll-bars . left)
(cursor-color . "purple")
(cursor-type . box)
(top . 30) (left . 150) (width . 89) (height . 56)))

--
Greetings

Pete

A morning without coffee is like something without something else.
Drew Adams
2006-06-21 20:15:01 UTC
Permalink
Post by Ehud Karni
(defun set-frame-value-all (key val) ;; change frame attribute
(aput 'initial-frame-alist key val) ;; for ALL frames
(aput 'default-frame-alist key val)
(modify-frame-parameters (selected-frame) (list (cons key val))))
Doesn't help here: Symbol's function definition is void: aput

See my message today replying to subject "Save the font setting" - it applies to all frame parameters, not just the font. Just get some frame to be the way you want all frames to be, then use `set-frame-alist-parameter-from-frame' or 'set-all-frame-alist-parameters-from-frame'. After that, use Customize to save the alists you updated (e.g. `default-frame-alist' and `initial-frame-alist').

If you don't want to do that, just customize those variables directly. What's good about the `set*' commands is that you need not know anything about how frame parameters are represented. See this doc: http://www.emacswiki.org/cgi-bin/wiki/CustomizingAndSaving#SavingFrameParameters.
Tim X
2006-06-21 22:36:13 UTC
Permalink
Post by Swidan, Firas
Hi,
I am unable to set the default foreground and background colors in all emacs
frames. I have added
(set-background-color "black")
(set-foreground-color "white")
To my .emacs. This changes the setting in the first emacs frame. However,
if I use
C-x 5 f
To open a new file in a new frame, the foreground/background settings in the
.emacs file do not seem to affect the look of the new frame.
Any ideas how to tackle this issue?
Many thanks and all the best,
Firas.
Either set the values in default-frame-alist AND initial-fram-alist or
far easier, use M-x customize-face <ret> default <ret>

Tim
--
tcross (at) rapttech dot com dot au
Swidan, Firas
2006-06-21 18:45:37 UTC
Permalink
Thanks for the help. I have tried Gil's suggestion and it seems that it did
the trick.

Firas.
Post by Gilbert Harman
Post by Swidan, Firas
I am unable to set the default foreground and background colors in all emacs
frames. I have added
(set-background-color "black")
(set-foreground-color "white")
To my .emacs. This changes the setting in the first emacs frame. However,
if I use
C-x 5 f
To open a new file in a new frame, the foreground/background settings in the
.emacs file do not seem to affect the look of the new frame.
Any ideas how to tackle this issue?
(add-to-list 'default-frame-alist '(foreground-color . "white"))
(add-to-list 'default-frame-alist '(background-color . "black"))
Gil
Loading...