Emacs for development and more
Lots of students "have to" use Emacs in different course, e.g. some programming courses. This is a little introduction for students who have not used Emacs before.
Java-mode
Java-mode helps you indent the code correctly, gives you color syntax and some other functionality. If Emacs does not load java-mode when you open a java source-file, you have to add ".java" in a variable called auto-mode-alist. Try the follwing code:
(setq auto-mode-alist (append
(list
'("\\.cc$" . c-mode)
'("\\.c$" . c-mode)
'("\\.C$" . c-mode)
'("\\.pl$" . perl-mode)
'("\\.el$" . lisp-mode)
'("\\.html$" . html-helper-mode)
'("\\.java$" . java-mode)
)
auto-mode-alist))
Here you see several examples to get different modes depending on the filename. This assumes that you have the different modes installed on your computer, and that's usually no problem if you have a standard Emacs-installation.
To activate this feature immediately set the cursor after the last parenthesis and press C-x C-e (read about keystrokes [1]). To make the changes permanent place the code above your startup-file (.emacs).
Syntax highlighting
font-lock-mode
There are several packages which can give you nice colors in Emacs. The most widely used is font-lock which gives you nice colors in most of the modes. font-lock is a part of the standard Emacs-distribution.
The easiest way to load font-lock-mode is to add the following line to your start-up file[2]:
(global-font-lock-mode)
JDEE
JDEE is a package which does more than just coloring and indenting your code. It also makes it easier to run different java-programs, e.g. java and javac. It gives you a Speed bar which gives you a nice overview of the code and lots of other features. JDEE has a web site , with user manual (which also is a part of the JDEE-installation).
You can find a nice picture, installation procedure and download link here . Note that the startup file on this page is made for Emacs 19.34. To set up JDEE for newer version of Emacsen (note the plural form ;)) you usually just need to add following lines in your start-up file:
(Provided that JDEE is installed in /emacs/lisp/jde-2.1.4 in your home directory)[3].
(add-to-list 'load-path (expand-file-name "~/emacs/lisp/jde-2.1.4"))
(autoload 'jde-mode "jde" "Java Development Enviroment" t)
Now you can load JDE with the commando M-x jde and the press enter. To make Emacs start JDE automatically you have to adjust the variable auto-mode-alist (see the section above about font-lock). Just replace java-mode (in the code) with jde-mode.
Commands to make Emacs a even better friend
C-h is almost the most important keystroke in Emacs. You use it to access the help-function.
Useful links
Footnotes
[1]: The convention for keystrokes in Emacs: to express "press a while pressing the Ctrl-key" the notation is C-a. This goes for all the keys not only a. The Ctrl-key is a modifier-key. The second most used modifier-key in Emacs is the Meta-key. Don't worry if you can't find the Meta-key on your keyboard. The left Alt-key is usually the Meta-key. If the left Alt-key doesn't work press the Esc-key and then the next key. You don't press the Esc-key and the other key simultaneously as you do with the Ctrl-key or Meta/Alt-key
[2]: The name of startup-file depends on the operating system you are using. In Linux/Unix it's called .emacs while it's called _emacs in Windows. The placing of the startup-file is always the root of you home directory.
[3]: The home directory is defined by the environmental variable $HOME. If you do not know what it is you can write (getenv $HOME) in any buffer, and then press C-x C-e when cursor is placed after the last parenthesis. The value of $HOME should appear in the bottom line in your Emacs-window. If it is not set the value will be ``nil''
| Languages: | Comments: | 0 | Aid: | 311 | User rating: |
|
|
| Last updated: | 2007-07-02 | Author: | henrikau | Read: | 3095 times |