My personal preference is to run just one copy of emacs all the time, as a server, and redefine the emacs command to talk to the running server. This is because it takes a second or two to start emacs, and I do a lot of editing; I would rather not wait for a second or two each time. I have a desktop icon which starts emacs when I click on it; then I just leave it running, typically for months at a time (ain't Linux great?).
Some useful resources:
% tar zxf lib-stuff.tar.gzIn particular, this contains the stuff needed for automatically time-stamping file headers, the stuff for doing fancy indenting automatically, stuff for automatically creating initial contents of new files (see lib/emacs/auto-insert-tkld.el for details, and the directory lib/emacs/insert/ for some templates which you can alter to suit yourself). It also contains all you need for the very useful Emacs Code Browser (ecb).
alias emacs="emacsclient --no-wait "so that the command 'emacs foo,c' actually talks to the emacs server process to get it to edit the file foo.c (which may or may not exist yet), and doesn't bother waiting for a response. If you inspect my .emacs you will see that the F12 key is bound to something that finishes editing the current document (but doesn't terminate emacs). In fact it is not necessary to ever finish editing; the F12 key is just a convenience, not a necessity. The .bashrc file also contains the stuff needed to make 'ls' output information in suitable colours.
If you have never used emacs before, type "control-H t" (the T can be lower- or upper-case) and you will be given a tutorial on the basics. All the keys and keystroke-sequences in emacs can be rebound to whatever you like. But I suggest you leave one key binding untouched: control-G is the abort key, useful if you are part of the way through some complex keystroke-sequence, or when emacs is expecting input to some interactyive question in the minibuffer at the bottom of its window, and don't want to continue that.
If you would like a printed reference card of the basics, look in /usr/share/emacs/21.2.93/etc/ (the 21.2.93 refers to the version of emacs you are using, and may differ on your machine).
Use the Help on the emacs toolbar for help. If you know vaguely what you are looking for, it can be quick and simple to do 'control-H A' (as in "help, apropos..") and then type a string, and emacs will look for all available internal commands that contain that string within their names. For example:
control-H A calenwill find 93 commands about calendar operations. Click on the 'Command:' associated with any of them to get more details; emacs is a self-documenting editor!
If you find yourself doing some repetetive editing chore within emacs, such as converting all the /*...*/ coments to //-style comments in some C or C++ program, you may find it helpful to define a 'keyboard macro'. Start with 'contol-X (', then do some sequence of keystrokes such as:
The Emacs Code Browser is a package that scans and analyses source code files in a variety of languages including C, C++ and Java, and displays windows that will permit you to move around the filespace, jump to functions, variables, classes, structures wherever they are defined, and so on. To start using ECB, you will need to stuff mentioned above. Then simply do this within emacs:
Esc X ecb-activateand to stop it, do this:
Esc X ecb-deactivatedot-bashrcYou can also use the ecb-hide-ecb-windows and ecb-show-ecb-windows commands. Or use the ECB button on the toolbar for a menu.
My .emacs file, and the huge number of autoloadable extensions, are all written using Emacs LISP, alias elisp, a very extensive and powerful programming language. Emacs contains a compiler for it, which generates the *.elc files you could see in places such as /usr/share/eamcs/21.9.93/lisp/ as well as in the ~/lib/emacs/ you can download above. There is an online manual but in printed form it runs to over 500 pages; you can also buy it from bookshops.
Remember, emacs has a very long history and a huge community of users, mainly researchers. If there is something you wish you could do in emacs (split a window vertically, click on a URL to get taken to it wherever it resides on Planet Earth, decrypt a PGP-encoded email message, ...), then almost certainly somebody wanted this functionality before you did and it's already been provided; simply look for it!