At school, I’m known as the Emacs guy; when people have questions
about configuring Emacs or making it work a certain way, they often
come and ask me. Sometimes, some people ask me why use Emacs at all?
Isn’t it a really old editor and aren’t Eclipse or Visual Studio much
better? I mean, they don’t have weird key bindings and have
intellisense, that’s surely better for a programmer, right?
I will attempt in this post to explain some of the reasons why I still
cling to Emacs. Believe me, I don’t think I have any emotional
attachment to Emacs; the reason I cannot leave it is that it seems
that the grass is yellower everywhere else. I’d love to be able to
use something like Eclipse for most/all of my work. Alas, I can’t (or
rather, I won’t).
Emacs has a GUI and a CLI interface
I often connect to my university’s server with SSH; since Emacs is
capable of running in a terminal, I can use it in those instances. On
my desktop, I can use the slightly cuter GTK interface. IDEs like
Eclipse are entirely GUI-based, this means that unless you can do X
forwarding, you cannot use it remotely. In my case, this makes Emacs
available in all instances where I need it.
The interface also consists entirely of text, so you can always use
the very useful editing features that you are used to (e.g. searching,
copying, etc.). One of the most common example is using the search
function in a customize screen to find a certain parameter.
Emacs can be entirely controlled by the keyboard
Related to the point above, Emacs can be worked without ever touching
the mouse. This is necessary for working with the CLI interface, but
it also allows me to never reach for the mouse when I’m using Emacs.
As many Emacs (and Vim) users will tell you, constantly reaching for
the mouse can slow you down considerably.
Also, I’ve been using a laptop exclusively for the past 3 years; a
track-pad is not as precise or fast as a real computer mouse, so I’m
happy when I can perform operations without touching the track-pad.
Emacs has the mini buffer
The mini buffer in Emacs is usually activated with the M-x
key
sequence and allows the user to type the name of a command. For
operations that don’t have a keyboard shortcut, it allows the user to
invoke them with the keyboard. No need to hunt down in a series of
nested menus to find the command that you want. The mini buffer also
allows for auto-completion and history navigation, so the next time
you need to run that command, you can get to it much faster. With a
GUI, you’d need to re-navigate the menus.
Emacs is self documenting
Emacs comes with a complete documentation system; if I want to know
what keyboard shortcuts are currently established, I can type C-h b
to have the complete list. C-h k
can tell me what command a
particular keyboard shortcut. With C-h a
, I can find the commands
that match a certain regular expression, which is useful to find a
command that you don’t know exists. The help system also includes a
very complete tutorial and info pages on Emacs, Emacs Lisp and many
packages.
Emacs is easy to configure
If you want Emacs to behave a certain way, but don’t know how, you can
go to the #emacs IRC channel on irc.freeenode.net and follow these
simple steps:
- Ask your question
- Copy the answer given to you by a helpful user
- Paste it in your .emacs
- Try it out
It’s that easy to add new configurations to Emacs. If editing Lisp
code isn’t your cup of tea, Emacs also has the customize mode to help
you out, and this will generate the Lisp code for you.
Configuration being a text file, it means that it’s a great idea to
put it under revision control. Push your configurations to a central
server and pull them when you use another computer.
Emacs works with all sorts of files
There aren’t many types of files that Emacs doesn’t recognize.
There’s a major mode for nearly every programming language you can
think of, and for languages you cannot think of.
This trimester, I have four classes that use four different languages:
Java, C, C++ and Scheme. I use Eclipse for Java, because that’s
required by our professor, but for the other three classes, I use
Emacs. In my free time, I also like to play with Haskell and OCaml,
which are both supported by Emacs. In the past, I also used Emacs to
edit R code, GAMS code (a research operations language), Python code,
JavaScript code, Clojure code, etc.
Eclipse is great at working with Java and Visual Studio is great at
working with C#, but they’re less great with other languages. I don’t
want to have to learn many different tools (with different menus,
shortcuts, etc.) to work with the languages I need to use. This is a
major reason why I use Emacs; all the basic operations (and sometimes
not so basic) that I use are the same regardless of the language I’m
editing. That’s very important in keeping my productivity high; I
often delete entire lines in Eclipse (Ctrl+D) because I wanted to
delete a single character. I cannot imagine what sort havoc I would
wreak if I had to use 5 different editors/IDEs.
Emacs has many very useful modes
Emacs is usually made fun of for having a Tetris game in its default
distribution. “Why the *@!& does an editor have a Tetris
implementation!?†people ask. I agree that Tetris is not terribly
useful, but what Tetris shows is what’s possible to implement in Emacs
by its users. Here are some non-trivial modes that I use that are
extremely useful:
- calc-mode: a calculator that can work in RPN or infix mode, that
has support for large integers, rational numbers, complex numbers,
vectors, algebraic expressions, etc. The things you can do in that
calculator could be the subject of an entire book. And it’s easily
accessible:C-x * *
to bring it up and again to make it disappear.
It integrates quite nicely into my work-flow. - epa-mode: an integration with gnupg making it seamless to open
encrypted files, modify them and encrypting them again. I use it
for my master password instead of a more involved solution like
KeePass. It can also be used to encrypt part of a file by selecting
the text and executing the commandM-x epa-encrypt-region
(no need
to find that in a menu ;)) - org-mode: people have switched to Emacs for this one mode; it’s
a mode to edit structured documents (sections, subsections, lists,
etc.) It’s used to maintain todo lists, to take notes, to plan
projects, etc. There are many videos on the web about it, I suggest
you watch them, because org-mode has too many features to list them
in this simple bullet point. - ido-mode: when people in Eclipse need to view another opened
file, they click on the correct tab; to open a file, they double
click on the file in the project list. Emacs users use the keyboard
for both activities, but by default, the interface is pretty minimal
and not terribly efficient. This is where ido-mode comes in: it
makes it much faster to open files and switch buffers by showing the
list of choices, filtering it as you type, giving you the option of
having flex completion (i.e. “abc†would match the string “a##b#câ€),
etc. Watching a veteran ido user switch buffer can make the
spectator dizzy. - anything: anything is similar to OS X’s QuickSilver utility; you
activate it, start typing what you want and it’ll show you all the
possible results, organized by categories. By default, it looks at
the files in the current directory, and the opened buffers I
believe, but you can configure it to find all sorts of things, such
as Emacs commands, man pages, recently opened files, functions, etc. - occur-mode: a small mode that I use quite often; you give it a
regular expression and it’ll find in that buffer all the occurrences
of that regex and display them in a new window that you can
navigate. Quite useful! - ibuffer: ibuffer can be used to perform operations on many
files. For example, if you wanted to replace all instances of “fooâ€
with “bar†in all the opened C files, you’d go to ibuffer, mark the
C files, pressU
and all the files would be changed. - tramp: you can open files over an SSH link, an FTP link, you can
open files using sudo, etc.
And there are many, many other very useful extensions to Emacs that I
haven’t mentioned here. The good extensions are designed in such a
way that they can easily be integrated without disrupting your
workflow.
Conclusion
Emacs is not perfect, it is lacking in many regards:
- It has no multi-threading support
- Elisp is not a great language, and is quite slow
- Using multiple major modes in a file sucks (e.g. PHP + HTML +
JavaScript) - Most programming modes have no semantic understanding of the
language they support, and thus offer no facilities like
intellisense, or re-factoring. (I’m not sure what the progress of the
semantic mode is; please comment if you know.)
But I think that for the most part, it compares favorably to the
modern IDEs. In the next few years, I imagine that Emacs will start
gaining and solidifying the IDE features that many users want. I
don’t know what IDEs will do; I would hope that they’d take a step
back and learn some of Emacs’ lessons and offer an experience that
power users can appreciate more.
Source:http://gnuvince.wordpress.com/2012/02/19/why-i-still-use-emacs/