emacs 

Send to Kindle
home » snippets » emacs


Pages
customize        
elisp        
evil        
keys        
slime        
whitespace        



Keys   Migrating from vim   |   Sites Page   Wiki   Elisp Reference   emacs-starter-kit

Plugins to explore
grep-find, eshell, run-python and slime

Available keys

    M-p    M-c    M-t / C-t   M-u    M-i
    C-<digit>
Modelines
-*- mode: modename; var: value; … -*-

Learning Steps

Try out

Are we in a terminal or a GUI? (in a multiTTY environment)

What we really want is code that executes for each new frame, checks whether the frame is windowed or terminal'd, then sets the colors. Naturally, there's a hook for that: 'after-make-frame-functions The following code defines a function that sets colors for a frame depending on whether or not the frame is windowed, then adds that function to this hook:

(defun my-set-display-for-windowed-frames (frame)
  "Set display parameters for the current frame the way I like them."
  (select-frame frame)
  (if (window-system frame)
      (progn
    (set-background-color "#003344")
    (set-foreground-color "white")
    (set-cursor-color "red"))))
(add-hook 'after-make-frame-functions 'my-set-display-for-windowed-frames)

We need to do one more thing to complete the picture: This code is sufficient to get all frames created after the add-hook to get configured by the function. However, the first frame Emacs opens when it first starts up is opened before .emacs is evaluated, so it doesn't get the colors. Thankfully, the frame settings are wrapped in a function, so we merely need to call it on the already-opened frame:

(my-set-display-for-windowed-frames (selected-frame))