This is a book that attempts to teach people to use the GNU Emacs editor. My original plan was to create a series of screencasts on this topic but I had a long conversation with Zed Shaw (the author of the series of books) in which he suggested that I try to write a companion book for the screencasts. That's how this book has come about.
My intention is to write one chapter per screencast. This is not a strict rule but every time I do a screencast, a companion chapter will be released.
This book is going to be a "work in progress" for a while. It's my first foray into the world of serious technical writing and will have a lot of beginner mistakes. If you find errors in the book or have suggestions for improvements, please send them to so that I can incorporate them and give you credit.
I will keep the content of the book and the screencasts available online for zero cost for the foreseeable future. I might decide to offer printed versions of the book or some other value adds for money later. I'm undecided about this.
GNU Emacs is a programmers editor. That is, it is a text editor that is designed for programmers. It is possibly one of the oldest pieces of software that are still in popular use. While it does show signs of age, it still has a large number of users and is actively developed and updated even today.
GNU Emacs is often, as in the title of this book, described as an editor and that's what it is. However, it has one property which has strained this definition a little which is that it is "extensible". This is the spirit of Emacs, its selling point and the reason why Emacs users continue to use what seems like an outdated and old fashioned editor when newer ones show up.
To understand what this means, think of your favourite programming language. You have "primitives" which are low level functions that are hardwired into the core of the language. Emacs, in essence, is an implementation of LISP with text manipulation primitives. This means that when you perform an editing operation, you are actually running a bit of lisp code that actually modifies the state of the interpreter. Now consider that the actual lisp primitives are available for you to play with directly. This changes Emacs from a text editor into a programming platform for text based applications (one of which is an editor).
If this sounds a little unusual, it's because it is. Many applications are customisable and extensible. Most have sophisticated plugin systems and allow people to write extensions for it. Many have embedded scripting languages that allow people to alter parts of the application without rebuilding it. Emacs has two peculiarities in this regard. The first is that the integration of the extension language is deep and tight. It's not bolted onto Emacs after it was coded up in C to make it "extensible". 1. The second is that instead of using a "toy" language, the original authors of Emacs used a full fledged, although now dated, programming language as the extension language. It made it possible to write general purpose programs inside Emacs. You could program games, write PIMs, write apps. that communicate with the network like mail clients and web browsers, take advantage of the UNIX shell and all sorts of other things. These two factors give Emacs its power and longevity.
Apart from this architecture making Emacs very extensible, it also makes it uniquely customisable. There's a common joke amongst Emacs users that you can't use another programmers Emacs and the reason for this is that people have customised it endlessly to suit their own way of working making it "theirs" in some sense. This given people a, perhaps false, sense of power over their environment.
Emacs has been around for a long time and it's been serving a single purpose for it's entire life - to edit text. This means that it has accrued many features that made to scratch the itches of people who type a lot. As Neal Stephenson has said in his excellent essay "In the beginning there was the command line" 2,
In other words, the engineer-hours that, in the case of Microsoft Word, were devoted to features like mail merge, and the ability to embed feature-length motion pictures in corporate memoranda, were, in the case of emacs, focused with maniacal intensity on the deceptively simple-seeming problem of editing text.
People who use Emacs regularly have learnt these keystrokes and internalised them making them extraordinarily adept at manipulating large amounts of text. I hope to share with you some of these "tricks" as we progress through the book.
Naturally, a piece of software this old will have a long history. The Emacs wiki has that describes the beginnings and evolution of the editor. We won't go into that right now but it's useful to know that there are two popular variants of Emacs that exist today. The first, which is the subject of this book, is GNU Emacs. It is the version of Emacs released by the Gnu project and the version that the author uses. The second is Xemacs which was a fork of the Gnu version earlier on. While the basic editing commands are the same, the lisp variant used to customise and extend it is not compatible with the dialect I describe in this book.
Emacs is available for Gnu/Linux, Windows and OSX (and a host of other platforms as well).
Emacs is available for most Gnu/Linux machines through their standard package management programs. This means that if you're on a Debian based distribution like Ubuntu, doing
sudo apt-get install emacs
will get you a version of Emacs that you can run. There are similar commands for other distributions.
The Gnu Project maintains downloadable versions of Emacs at . There is also a FAQ on their website describing exactly what to download and how to install it. You can get the FAQ at . The short answer is that you need to dowload the -bin-*.zip
package for your platform (e.g. ) and unzip it. It will contain the binary which you can run and create a shortcut to.
GNU Emacs for Mac OS X can be downloaded at .
%TBD : Need to flesh this out for OSX, Windows and other distribution.
It's popular in the tech. community to get religious about ones own technological preferences. There is a humorous undercurrent in many of these fora and as long as one doesn't take it too seriously, it's a fun way to kill some time.
However, when people seriously believe that their own technological choices are the "one true way", it gets counterproductive at best and nauseating at worst. While I use Emacs for many of my day to day tasks and have strong opinions about many pieces of software, I try to keep an open mind about this and don't take myself too seriously. I encourage all of you to do the same.
Emacs has some interesting features, some compelling ones and has a large user base and I'm writing this book to offer a way for newcomers to learn how to use it. If you're one of them, welcome.
This book supplements the https://emacsmovies.org
screencasts. However, I've tried to make it a standalone book as well. You should keep your computer ready and try out the exercises in the sections. Welcome to Emacs and good luck.