As a programmer you will spend most of your time inside an editor. Editing Eiffel code, editing Makefiles, editing XML or XSLT files, editing sources in other languages. You will also spend time in the editor when writing email or posts to newsgroup. And if you write documentation you will spend even more time in the editor. Many programmers use different editors for all these environments. If there's a new language they will have to work with, they will spend time learning a new editor. Programmers typically don't spend enough time in a single editor to make customisation worthwile. And when they switch editors they have to redo all that customisation again.
But why not use a single editor that allows you to edit everything under the sun, that you will be able to use with every language? Why not become proficient in a single editor, learn to master it and use it for the rest of your life? There's only one editor that truly does everything, and that editor is Emacs.
Here some compelling features that Emacs has to offer the Eiffel programmer:
Unix systems typicall have Emacs installed. If not, it's easy to download the sources for Emacs from the main Emacs site and compile it youself.
On Windows you can use the Cygwin layer. If you install it's X Window server, you can run Emacs in its X Window GUI mode, just like a Unix machine would.
If you prefer a more native version of Emacs on Windows, you can download these as well.
By default syntax highlighting isn't enabled, but it's easy to turn it on. And it demonstrates how you can customize Emacs using the new customization features.
Emacs can be customized by browsing the customization groups. You can do this interactively by choosing “Options” from the menu and next “Customize Emacs”.
But let's do it slightly faster by choosing a specific option. There are two things you probably want to do immediately:
Press C-h v (Ctrl+h followed by v). You can now type in the name of a variable. Enter ‘pc-selection-mode’. Note that you can use the Tab key to get completion for the variable name. Emacs will now show the current value of this variable and offer you the option to customize it. Click in customize with your third mouse button (or but the cursor on it and press Enter). You can now toggle the value so it is enabled. Click on “Save for future sessions” to save it permanently.
This makes Emacs behave more like a Windows application. But still Ctrl+V will note paste, Ctrl+C will not copy, etc. For this you need to enable cua-mode. I don't think this is available on Unix, and enabling it will interfere greatly with your ability to use Emacs on different OSes, but for hardcore Windows users it might be an option. CUA mode can be enabled by selecting it from the Options menu, or typing in C-x cua-mode. Afterwards C-x won't do what it normally does of course. Use Esc x instead.
We'll do the same to enable syntax highlighting. We will enable this for all modes. Press C-h v. Enter ‘global-font-lock-mode’. Again use the Tab key to avoid typing too much. Click on “Customize” again and “Toggle” it to on. Save it for all future sessions.
Emacs doesn't natively come with an Eiffel mode, but it's easy to install one. Here's how:
(require 'eiffel) ;; the following extension are recognized as Eiffel files (add-to-list 'auto-mode-alist '("\\.e\\'" . eiffel-mode)) (add-to-list 'auto-mode-alist '("\\.ge\\'" . eiffel-mode)) ;; in case all your Lex/Yacc is done with Eiffel, define this (add-to-list 'auto-mode-alist '("\\.y\\'" . eiffel-mode)) (add-to-list 'auto-mode-alist '("\\.l\\'" . eiffel-mode))Next time you open a file with one of the four listed extensions, the Eiffel mode will be activated.
Emac's completion support is static, not dynamic. So it does not compile your code on the fly and add new features. That's a disadvantage, but an advantage as well. If your code doesn't compile anymore, Emacs will still have completion support, while ISE Eiffel and Delphi for example first need to be able to compile the code before they enable programmer support again.
You will need to download gutentag for completion support. Usage is simple. If you have a system.xace file in your directory, simply say:
gutentag system.xace
When it finishes, you will have a TAGS in that directory. You can load that in Emacs with M-x visit-tabs-table. After it has been loaded, you have some new features:
Tips on how to customize the Eiffel mode.
Emacs has its own terminology and it is sometimes different from what we're used to nowadays. That's because Emacs predates most modern software we use.
Some useful keybindings:
You probably want to do some custom key bindings as well. The way to do that is to put some Lisp code in your ~/.emacs file. The following example shows how to bind the keys on your numeric keypad, useful for programmers who are coming from the original IBM PC area:
(global-set-key [C-kp-left] 'backward-word-nomark) (global-set-key [C-kp-right] 'forward-word-nomark) (global-set-key [C-kp-home] 'beginning-of-buffer-nomark) (global-set-key [C-kp-end] 'end-of-buffer-nomark)
Emacs doesn't use any of the function keys, so these are ideal for your custom key bindings. I like to comment and uncomment code with a single key press, and that's what the following key bindings accomplish:
(global-set-key [f3] 'comment-region) (global-set-key [f4] 'uncomment-region) (global-set-key [f7] 'goto-line)
The binding to f7 in the example above allows you to jump to a given line.
You can also bind keys to custom Lisp code. The following example demonstrates scrolling lines up and down in your buffer using the f11 and f12 keys:
;; one line at a time scrolling (defun scroll-n-lines-up (&optional n) "Scroll up N lines (1 by default)" (interactive "P") (scroll-up (prefix-numeric-value n))) (defun scroll-n-lines-down (&optional n) "Scroll down N lines (1 by default)" (interactive "P") (scroll-down (prefix-numeric-value n))) (global-set-key [f11] 'scroll-n-lines-up) (global-set-key [f12] 'scroll-n-lines-down)
Tips on how to change the default font in Emacs.
Some useful and very powerful other modes:
In an amusing Usenet thread, Alan Mackenzie claims that:
Emacs is decades old rather than months old, and it has been honed to gleaming efficiency in that time.
David Kastrup, of AUCTeX fame, objects:
Uh, gleaming efficiency? Sorry to disagree, but Emacs is a traveling junk yard and freak show. A junk yard which has got everything, and building materials for building everything else. It's not as much "honed" rather than having lots of people making it their home and improving their personal corner of the junk yard. People are always running around with soldering irons and swapping their favorite pieces of scrap and construction recipes. It is a gathering ground for Mad Scientists(TM) in the text processing area.
And on Alan Mackenzie's claim that he finds most other editors clumsy, David opines:
They are not necessarily clumsy. Just not accommodating. Emacs is probably the clumsiest and most dissociated piece of software ever. But it works with you, lives with you. It's a walrus tangoing with you, following your lead like a feather. If you have learnt how to properly lead and don't make it flap on your feet.
NOTE: This HTML page requires a browser that supports XHMTL and Cascading Style Sheets 2. |