“G*d damn it, you’re a programmer. Start using an editor you can damn well program.”- Magnar Sveen
If you’re a true programmer you gotta love that quote - I sure do!
To start off with, we have to get it clear what Emacs is. According to the official website:
“Emacs is an extensible, customizable text editor - and more. At its core is an interpreter for Emacs Lisp.”
But what does that mean? Emacs is extensible. Well… most editors are, you can just download a plugin and install it. Emacs is customizable. Again, most editors are. You can just grab your mouse, browse through the menu system and hopefully you’ll find an option for it.
Let’s try it again. Emacs is extensible. Yes, it sure is! Emacs’ core is written in C, which includes an interpreter for Emacs Lisp. The rest of Emacs is written in Emacs Lisp itself. If you are programming Ruby in Emacs you are probably using a major-mode called ruby-mode, which is defined in a file called ruby-mode.el. It provides you with indentation, syntax highlighting, etc. It’s just a simple Lisp file. If you don’t like it, write your own or find another one, open the file in Emacs, evaluate the code and your done. No installation process, just code. That is what I call extensible. Simple and no limitations.
I hope we agree that extensible means different things. Let’s move on to customizable. Emacs is customizable. You can (but should not) grab your mouse and browse through the menu system. Remember that Emacs is mostly written in Emacs Lisp? Each Emacs package contains a bunch of variables and functions. If you want to customize some behavior, just change the value of a variable, evaluate it, and you’re set to go. If you want even more in depth customizations, each mode provides hooks. And if even that isn’t enough, just edit the code and make the changes yourself. Again, simple and with no limitations.
I agree that Emacs is not for everyone. To use the full potential of Emacs, you should know some Emacs Lisp. But why is this intimidating for programmers? You should be delighted that you can program your editor. Sometimes when I ask people why this is so, they say: “That’s great, but you have to write Lisp”. I still argue: No, you don’t have to write Lisp, you have the priviledge to write Lisp, it’s an awesome language!
Enough talk! Let me show you how easy it is to extend Emacs. Let’s say you realize that you quite often take a line of code, copy it, paste it below and comment out the line above. Maybe your editor already has this functionality. But let’s say you are like me and you want stuff to work exactly the way you want it but the built in functionality puts your cursor at the beginning of the new line and you want it at the current position. In most editors you are screwed and you have to live with it. Feels good when someone is controlling you, right!? No, it does not! Let’s make it work exactly the way we want it.
Ohh my god, the horror, all the code, all the parentesis, can’t, look, directly, at, it…
If you can figure out a way to do it more simple and better, please do let me know. The best part of all of this, coding Emacs Lisp is a loooot of fun! If you consider yourself a decent programmer, at least give it a try!