sábado, agosto 16, 2008

How to start with emacs [2]

Emacs uses a configuration file that is by default placed in your home directory, the file is called .emacs (I don't know if on win32 systems is also called .emacs). This file contents is elisp code, so for full control of emacs it's imperative learn elisp, but I still didn't learn elisp and I'm an emacs user :), so you can learn elisp while you are looking for snippets of code.


I will have to explain some concepts that are important to understand why emacs behave in the way that it does.

In emacs there are buffers, there is the minibuffer that is where you type the emacs commands (or elisp interactive functions), and the other buffers could represent an opened file, a pipe, or just a temporary editing space that is not attached to a file, the name of the last type of buffers start and end with *, for example *scratch*

Emacs has something called 'modes', it's something like the way that a determined buffer must behave, for example if you are going to open C source code file the c-mode should be loaded, and it will help you in task of develop with the C language. There are 2 kinds of modes, the major and minor modes, one buffer can only have one major mode and zero or more minor modes.

First tweaks

Emacs is a software with a huge history and tradition, so there are some things that for somebody that is formed in the last 10 years in computing terms there some musts that you must have in you emacs config file, like the transient-mark-mode

The transient mark mode highlights the selected region of text, by defaults this is disabled so I recommend you enable it with pasting the following in your .emacs

(transient-mark-mode 1)

Fill you name and email to let the modes that need that information could use, this is done with the following snippet of code
(setq user-mail-address "homer@simpsons.com")
(setq user-full-name "Homer J. Simpsons")

If you like to use Ctrl+g to jump to a line number then you should add the following code

(global-set-key [(control g)] 'goto-line)

One of the sweetest feature that must have a text editor is syntax highlight, well emacs has this, but disabled by default, with the following code you will have it enabled always

(require 'font-lock)
(global-font-lock-mode t)

I think that this is enough for this entry, the next entries probably will be more fun to write and read, because i will start talking about the major modes, one mode per entry, probably the next one will be the C mode.

No hay comentarios.: