I am posting this for nforbes. - grep420
One of the great things about emacs is that you can change the looks of it by editing files in a programming language called "lisp". It's actually a very simple programming language, and with the help of emacs, it can become quite useful. Let's get started.
First, open up emacs, and get up a find file in the minibuffer. This can be accomplished by pressing ^X-^F (^ means Ctrl). It should look similar to this:
Find file: ~/
Locate the file ~/.emacs, and open it. .emacs is the file that emacs trys to autoload to get settings from. If it doesn't exist, let emacs create it for you. Now we can start doing some cool things. Most commands in lisp for emacs look like this:
(set-variable 'option value)
These options are equivalent to pressing M-X (M means Alt), and then the option. For example, try M-X global-font-lock-mode. This is the same as writing (set-variable 'global-font-lock-mode t) in your .emacs. However, by putting that line in your .emacs, every time emacs starts, it will automatically execute M-X global-font-lock-mode. Pretty neat, huh?
A good way to edit your .emacs is to use the built-in emacs customization interface. Type M-X customize-browse. You can browse through all the settings available to emacs here. When you select to turn one on (or off), it will automatically add that to your .emacs as if you had written it yourself!
Next, let's do some key bindings. These are neat because you don't have to remember specific M-X commands, just the key that executes them. Let's see how we can have F1 and Shift-F1 move forward and backward in the buffers.
Some people like to have a different file for key bindings, and they generally put this in the /usr/share/emacs/site-lisp (or wherever your site-lisp directory might happen to be). By doing this, you can easily organize all your emacs settings. So get up the find file dialog in the minibuffer again, and (making sure you are root for this one), open /usr/share/emacs/site-lisp/site-keys.el. .el is the extension used for emacs lisp files.
Let's make a new keybinding. this can be accomplished by doing
(global-set-key [key] 'option)
We want to bind F1 to 'go to the next buffer' (the command for this is 'exhume-buffer'), and Shift-F1 to 'go to the previous buffer' (the command for this is 'bury-buffer'), so what we can do is this:
(global-set-key [f1] 'exhume-buffer)
(global-set-key [(shift f1)] 'bury-buffer)
Note the parenthesis around "shift f1". emacs does not have an interface (that I know of) for adding new key bindings, so you'll have to write this file yourself.
emacs does not automatically load the files in /usr/share/emacs/site-lisp, so we'll have to add this file as a library to our .emacs. Switch to your .emacs buffer (M-X bury-buffer until we load these key bindings), and add a library line:
By default, emacs loads libraries from its shared site-lisp directory. If you saved this file somewhere else, include the path to the library as well.
You can also customize emacs' colors. Again, it's good to put these in a seperate file, so open up /usr/share/emacs/site-lisp/primary-faces.el
Let's just do some easy stuff. You should be able to catch on to these settings, so I won't bother explaining all of them.
(set-face-background 'default "black")
(set-face-foreground 'default "gray90")
(copy-face 'default 'bold)
(copy-face 'default 'italic)
(copy-face 'default 'bold-italic)
(copy-face 'bold 'zmacs-region)
(copy-face 'bold 'isearch)
(copy-face 'bold 'highlight)
(copy-face 'bold 'primary-selection)
(copy-face 'bold 'secondary-selection)
(copy-face 'default 'left-margin)
(copy-face 'default 'right-margin)
(set-face-background 'zmacs-region "steelblue" )
(set-face-foreground 'zmacs-region "grey90" )
(set-face-background 'isearch "lightblue" )
(set-face-foreground 'isearch "black" )
(set-face-background 'modeline "deepskyblue4")
(set-face-foreground 'modeline "linen" )
(set-face-background 'highlight "lightblue" )
(set-face-foreground 'highlight "black" )
(set-face-background 'primary-selection "steelblue3" )
(set-face-background 'secondary-selection "steelblue4" )
(set-face-foreground 'secondary-selection "grey90" )
The one thing you may be curious about here is 'copy-face'. copy-face looks like this:
(copy-face 'face-from 'face-to)
It gives the 'face-to' face the attributes of the 'face-from' face, and nothing more.
That's pretty much how my primary-faces.el looks. Now we need to load the primary faces in our .emacs. This is accomplished by using a require require line (note: this is note a library because we use 'provide' in our file):
There's a lot more customization available in emacs; this is just the tip of the iceberg. For other commands, you can type ^H-I and scroll to the 'Elisp' section. Be sure to check out some of the other help topics available, too.
If you have any questions about this tutorial, feel free to send me an email (<email@example.com>), or hop on irc.blessed.net (EFNet) and join #redhat.