4757 comments
2071 subscribers
4481 on Twitter
Subscribe! Feed reader E-mail

Emacs basics: Changing the background color

One of the first things you’ll probably want to change about Emacs is the default face. This controls the foreground color, the background color, the font, and other attributes. For example, many graphical environments give Emacs a background of white. If you prefer a black background (which can be less tiring during long periods of use), you can change the background to black my customizing the default face.

To change the background color and other attributes, use the command M-x customize-face, and specify default as the face to customize. Change the attributes and the sample text will reflect your settings. When you are satisfied, select Save for future sessions. Your changes will be saved to ~/.emacs and reloaded the next time you start the editor.


This is a draft for Wicked Cool Emacs, a book that will be published by No Starch Press. (if we manage to get it all together! =)

Short URL: http://sachachua.com/blog/p/5635

8 Responses to “Emacs basics: Changing the background color”

  1. You have a typo: “…to black [my/by] customizing the default face…”.

  2. Along these lines, some of your readers may find the color-theme package interesting. I’d point out to them that it’s a whole set of faces, rather than just a background or a foreground, that are intended to fit well with each other.* Given how easy it can be to try them out before selecting one, there’s probably not much harm in recommending it to beginners, either.

    I use it, too, with just a few custom faces set on top of it. Who knows how much time it saved me from having to futz around with so many different faces…

    * Well, okay… some of them “fit well together” and really are nicely thought out. Others appear designed by whomever brought “Hot Dog Stand” to Windows 3.1.

  3. I trust it’ll be ok if I share this. Perhaps someone will fix it. I apologize if it is excess baggage.

    Some time ago, I enquired on the emacs list about having different background colors for each frame. I REALLY need some clues on the desktop, as it is always cluttered with at least 10 windows and frames, and having several tasks going at once, it’s extremely helpful to have these visual clues, of corners of frames here and there on the desktop.

    A tentative solution was proposed by Kai.Grossjohan on that list. It works well enough, I suppose, but it’s always been a little broken. It’s a one off, as he suggested. It works really nicely after the first new frame, which is a clone of the originating frame on startup.

    One fantastic enhancement would be changing to different schemes. Judiciously selected background colors help. I possess not the skill to write the more complicated version.

    Here it is:

    ————-%—————————
    ;;—————————————————————————-
    ;; Cycling frame colors
    ;; Kai.Grossjohann
    ;; Newsgroups: gnu.emacs.help, 5 Aug 2002
    ;;———————————-
    (defun my-next-bg-color (frame)
    (let ((x (assq ‘background-color default-frame-alist)))
    (setq default-frame-alist (delq x default-frame-alist))
    (add-to-list ‘default-frame-alist
    (cons ‘background-color
    (cond ((equal (cdr x) “blue”)
    “black”)
    ((equal (cdr x) “black”)
    “dark blue”)
    ((equal (cdr x) “dark blue”)
    “saddle brown”)
    ((equal (cdr x) “saddle brown”)
    “blue1″)
    ((equal (cdr x) “blue1″)
    “dark olive green”)
    ((equal (cdr x) “dark olive green”)
    “maroon”)
    ((equal (cdr x) “maroon”)
    “blue violet”)
    ((equal (cdr x) “blue violet”)
    “MediumPurple”)
    ((equal (cdr x) “MediumPurple”)
    “RoyalBlue3″)
    ((equal (cdr x) “RoyalBlue3″)
    “DeepSkyBlue4″)
    ((equal (cdr x) “DeepSkyBlue4″)
    “blue”)
    (t “black”))))))

    (add-hook ‘after-make-frame-functions ‘my-next-bg-color)

  4. OK, thanx to this post I finally figured out how to make the font change permanent. (You can also just hit shift + mouse button to change the font, but that’s not permanent.) However, I’m still scratching my head over how to change the color. Perhaps some examples? What color names are valid? If you’re doing a book, this is a good idea….
    The color theme package also seems interesting. Will check it out

  5. Thank you very much. For default came after the customize face and then after pressing enter defualt all comes. In that there is an option for default.

  6. I tried the color-theme package @Bob@ recommended. When using “doremi-color-themes” to cycle themes, this is probably the best way (as in easiest way) to change emacs colors. You don’t have to fuss with configuration files, look up colors, just a pick a theme you like and “Boom” you’re done. You can go back to what you are doing. The whole thing took me about 5 minutes. Installing the dependencies was the hardest part.

  7. For making changes i need to press enter on the [value] node. Then to actually see the changes i need to press enter on the [SET for this Session] node. For font family I just saw a box that said default…there was no option to change it. I guess this means I don’t have any console fonts installed?

    @bob thx for the recomendation!

  8. Oh… emacs for the masses.
    Thanks for your simple and effective explanation. :)

Comment, share a thought, ask a question...

Please comment as you, not your organization.





On This Day...

  • 2012: Emacs: Telling external processes about terminal capabilities, and watching over other people’s shoulders — Justin Giancola (@elucid) wanted to use full-ack.el to search through his project files using the Ack tool, but Ack refused [...]
  • 2011: Of recipes and memories — Kevin Waite asks, “What format do you use to keep your recipes? Do you use Freemind or Org Mode?” [...]
  • 2010: Weekly review: Week ending Jan 17, 2009 — Work [/] Prepare company profiles for upcoming Innovation Discovery engagements [X] Learn more about facilitation Relationships [X] Spend more time with family [...]
  • 2010: What I want to talk about in 2010 — Following through on my resolution to give fewer talks, I’m thinking about what kinds of talks I do want to [...]
  • 2009: lifecampto — (click for larger version) Event details at lifecampto.eventbrite.com
  • 2008: Outlining Your Notes with Org — Large documents are almost impossible to write without outlines.  There’s just too much to fit in your head. Outlines help [...]
  • 2008: Fast-forwarding through small talk
  • 2008: Glasses, glasses — "You’re ordering glasses from the Internet? You’re braver than I am!" was the almost-unanimous sentiment I heard when I told [...]
  • 2007: Mirroring energy — One of the good things about this long-distance relationship with Simon is that I get to practice mirroring. I might be [...]
  • 2007: An examined life… — … feels like it’s worth living. I write a lot. That’s because letting a day pass without finding *something* noteworthy about it [...]
  • 2007: Grazing in the bookstore — I’m starting to feel a little strange in Powerbooks. Maybe it’s visual overload from of “SALE” signs everyone. Maybe it’s mental [...]
  • 2007: Sometimes the universe gives you a sign… — … and sometimes it brings out the pompoms and cheers you along the way! Winston Damarillo thanked me earlier for referring someone [...]
  • 2006: TODO lists in Emacs! — E-mail addresses removed. But it’s the real Stephen J. Turnbull… =) From: "Stephen J. Turnbull" Subject: Re: TODO extension for source code [...]
  • 2005: Reply from Leo Querubin — We are meeting with the committee to discuss these issues and will update you. E-Mail from Leo Querubin On Technorati: digitalpinay, issues, [...]
  • 2005: Digital Pinay 2005: Sent mail to Leo Querubin, Special Projects Chair of PCS — Received from Leo Querubin: Hello Sascha, Your email was forwarded to me by Bombing of MediaG8way regarding your reaction to the Digital Pinay [...]
  • 2005: Mail sent to Ateneo CS and CompSAt mailing lists — Updated copy at http://www.livejournal.com/users/sachachua/6605.html . Please leave comments there. Miguel Paraz just forwarded a _very_ interesting contest application to the CompSAt-EB mailing list, [...]