Wednesday, 3 November 2010

Why EMACS is still important

«Hey you! Is that a VIM session?!»

Talking about EMACS in 2010 may seems stupid. But GNU's official text editor still maintains its charm, despite nearly three decades. Born from Richard M. Stallman's keyboard, EMACS is the editor of choice of different programmers scattered around the world, thanks to its main feature (it's programmable). I decided to try EMACS after a fight of years.
If you use EMACS enable immediatly the cua-mode The cua-mode sets the "copy-and-paste" and other controls with the keyboard shortcuts control-v, control-x, z-control, control-c, making more "human" the user interface and avoiding you to spend two hours on manual to understand what is a "region", the "yanc" command and the "kill" command. Using this "trick", I finally started using EMACS for real and not just for fun.

EMACS vs XCode vs Netbeans vs Eclipse vs...
EMACS can compete against an IDE?" No. It can't, at least not right now. It 's true EMACS is a text editor with a LISP engine then theoretically you can turn it into a IDE, but I've never seen anything like it. And I'm not interested to see it. The "universal solution" (or "silver bullet") does not exist. If I'm working a small project in C / C, a bash script or a python script, then I'll probably use EMACS; but to develop an iPhone App, a java servlet or a 3D engine I'll use a IDE to do object's methods analysis, to compile the project with ANT, to upload it to SVN, etc..

Why should I use EMACS?
Just for fun. To learn LISP. But the main reason is because EMACS is on any operating system. Well, if you're writing a shell script on a SSH session, then VIM is enough. But when you need to write some Python scripts, with C code, then EMACS is the choice. It's everywhere, has a huge library of macros, will work on Mac OS X, Windows and GNU / Linux and ALL EMACS macros (including "search and replace in selection "," Indent Code","open a shell","Open SSH session to server","Send a email to", ecc.) work on ALL systems which run EMACS . If you are a programmer, probably you will find difficult to use the C mode. Well, you have to configure the c-major-mode to work as you want. At the end of this post, I'll show my personal .emacs file.

EMACS isn't good as VIM
If you talk just about personal preferences, I don't say anything: everyone has his preferences. I was a VIM user, but I finally passed to EMACS after some days of XCode. Why? XCode indents wrong my Objective-C code if I forget some parenthesis (using Objective-C it happens very often). I felt the lack of this advanced feature and I realized that Emacs can do the same, changed my feelings on it.
There's some things I would like to see in next EMACS release: first, set the default use of cua-mode, because in 2010 just two or three nerds are comfortable with "kill and yank". Second, set UTF-8 as default encoding. Third, a modern configuration interface (the "Customization Macro" was useful in the '80, but now is a bit obscure).

My .emacs file
Somebody has a very large .emacs file, filled with his own macros. I just want to use the c-style called BSD, with tab character as indentation method and four spaces as tab width.

;C programming style
(setq c-default-style "bsd"
         c-basic-offset 4)
;for c-mode, use tabs instead of spaces.
;Set tab width as 4 spaces
(setq-default c-basic-offset 4
                  tab-width 4
                  indent-tabs-mode t)

Last advice
Take a look at the Emacs Wiki: I found it very useful.
Happy hacking :)
Post a Comment