Learning GNU Emacs, 3rd Edition
For a programmer, it is reasonable to question whether or not a word processor or graphical IDE is the right tool to edit a simple script or properties file. IDEs like Eclipse have become universals hammers, and to some of their users, any file containing text looks like a nail. Specific tasks are rarely handled well by universal tools, and text editing is no exception. Dave Thomas and Andy Hunt, authors of The Pragmatic Programmer and founders of the Pragmatic Bookshelf series, recommend that programmers adopt a text editor as an essential utility in their collection of appropriately-suited tools. The tried-and-true text editor is enjoying a renaissance of sorts, and one of the most extensible and customizable applications among text editors is the venerable GNU Emacs.
Tutorials and documentation for Emacs are abundant, but they often prove time-consuming and ineffective for actually learning Emacs. The printed version of the official GNU Emacs manual reads more like an application programming interface (API) document than an instructional guide. This book is a refreshing break from the documentation many have come to expect. Imagine having a group of leading experts on Emacs at your disposal to teach you how to use it in a conversational, consultative style. That is what has been bundled into this book.
The extensibility of Emacs is considered both a key strength and a confusing weakness of the application. The Emacs community has created all sorts of additional capabilities for Emacs, ranging from the impressive to the absurd. The authors have done well to judiciously select which Emacs capabilities to cover. For example, while Emacs does have the capability to function as an email client, other applications have long superseded its ability. The authors have chosen not to cover this topic, and instead devote the available space to learning Emacs' core functionality -- powerful, efficient text editing.
This edition of the book uses the space gained by the removal of esoteric topics to flesh out areas of more common interest. Peripheral areas of Emacs, such as compatibility modes for programming languages (other than Java and Perl), have been left for the user to research after gaining a solid foundation on Emacs as editor and work environment. Integration with the major version control systems has been expanded to include Subversion alongside the age-old standards CVS, RCS, and SCCS. Coverage of support for Java and Perl has also improved, as well as sections for editing HTML and XML. Users wanting to tap into the power of Lisp programming for Emacs should find the coverage satisfying as well.
The pace of the material is comfortable, and the order in which topics are introduced allows the user to progress smoothly through the book. Users with some experience can skip past the first three chapters, but would be advised to read through them, particularly those who are self-taught (which applies to most Emacs users). Given the amount of time the average user spends in Emacs, picking up one or two time-saving shortcuts would be well worth an investment of a few hours. Instructions are given in a way that reflects the fact that there are multiple ways to achieve the same outcome; the authors do not attempt to foist "the only way" to accomplish something upon the reader. Some readers will find that bothersome, desiring instead a simple, straightforward heuristic for performing a task. However, the typical users of Emacs tend to be people who embrace the fact that the world is not a simple, straightforward abstraction. The book reflects the authors' awareness of this nuance.
Perhaps the most distinguishing feature of this book is the chapter devoted to the use of Emacs on different platforms. Unix, Windows and Mac OS X users receive equal acknowledgment. The precautions and insights regarding subtle differences in Emacs when used on particular platforms can reduce users' frustration when getting started.
The mnemonic devices and conventions used in the book allow users to
commit useful keyboard commands to memory. The memorization is further
solidified by the exercises sprinkled appropriately through each
chapter. Readers do not go for very many pages before it is time to be
at the keyboard again, harnessing the power of muscle memory to
reinforce the material presented. Those who spend any time at a shell
prompt or in console applications will find that their new mastery of
Emacs keyboard shortcuts translates into increased proficiency with
command-line operations as well.
...doing just what I just did? I mean, just once?
Vi would I want to learn emacs????
I've been using vi for over 20 years. From time to time, I have tried to learn emacs (seeing the benefits) but the learning curve seems so steep, relative to just sticking with the statuis quote. Short of taking a couple of months off to focus on this extensiveley, what's the best way?
"I'd rather be a lightning rod than a seismometer." -Ken Kesey
This review is amazing!
I haven't been this excited since Slashdot's review of "Learning GNU Emacs, 2nd Edition".
I'm a big tall mofo.
But given Emacs' startup time, you're forgiven.
It's like this:
Vi, vi vould I vant to learn emacs????
Intersting the author appears to be presenting the "atheist" point of view, into a subject the stirs religious rants amongst the editor's loyalist.
What I'd like to find and or write is a good PHP/HTML mode for emacs, or even a CPAN/CTAN clone for emacs modes and scripts.
Apocalypse Cancelled, Sorry, No Ticket Refunds
The GNU Emacs Manual available for free at http://www.gnu.org/software/emacs/manual/ is excellent. Printed versions are available too.
Emacs also comes with a built-in tutorial that is a good interactive introduction to Emacs.
If you are considering learning Emacs, yes, it can seem like an intimidating task. The interface and commands are nothing like what people are used to today. But it is certainly worth the effort learning Emacs and getting used to it.
"Instructions are given in a way that reflects the fact that there are multiple ways to achieve the same outcome; the authors do not attempt to foist "the only way" to accomplish something upon the reader."
Do the authors discuss the relative benefits and drawbacks of each method? Do they discuss when it is and isn't appropriate for each? More info on this would be helpful.
"Readers do not go for very many pages before it is time to be at the keyboard again, harnessing the power of muscle memory to reinforce the material presented."
This is not muscle memory. This can be called learning through use. If the reader were to repeat the intended action 5,000 times, then maybe it could be called muscle memory.
My impression from the review is that the book will:
Give me the basics of Emacs use, and how they differ sometimes on different platforms;
Give me mnemonics to memorize keyboard shortcuts;
Show me multiple ways of doing some things;
Show me how to use basic Emacs with different languages, in some common situations.
So, my understanding from reading the review is that this is an fairly thorough introduction to Emac use that is easy to understand and doesn't bother with extraneous material.
Am I off base here?
"Trolls they were, but filled with the evil will of their master: a fell race..." -- J.R.R. Tolkien on Olog-hai
I like Emacs and its brethren, however, I don't do software development in Emacs anymore. Full blown IDEs like Eclipse are really worth the power, especially since they are able to semantically understand source code.
However, when I just need to do some basic config file editing I use Jove which is a scaled down version of Emacs that has the same keys as Emacs but loads as quickly as vi.
Emacs works great though when I have to interact in a complex way with the shell. For instance, I find it very useful when used in conjunction with command line SQL clients for Postgres, Mysql, or Oracle. The history and multiple command buffers are great for working with these command line clients. When I work with Oracle DBAs they are often impressed with how powerfully I can use SQLPlus from inside of Emacs.
I learned emacs in school, but by far the most helpful thing was the PDF reference card I printed up and carried with me. You can get the emacs card at http://refcards.com/
Physicists do it with a big bang!
Emacs is a great operating system, but it needs a better text editor.
"Live Free or Die." Don't like it? Then keep out of the USA
534 pages, 437 of which contain a table of all the keyboard shortcuts.
I don't really see why your right hand would hurt much, but still, here's my trick for Emacs hand comfort: make sure you use a keyboard where the left Control key sticks out well. That way, you can press Control with only the side of your hand, instead of having to use your pinky finger.
Think of this as a sixth finger for your hand. The shape of your hand was intelligently designed to use Emacs that way.
cheers
..yet I hardly ever use it.
I used to use Emacs for development, vi for sysadmin, but once I discovered Vim, I've started using Emacs less and less for dev, except when hacking Lisp (using SLIME.. you just can't do Lisp effectively without an editor at least as powerful as Emacs).
I can really appreciate Emacs, and I love Lisp (being able to code some quick Lisp right in the middle of an email reply is pretty damn cool for instance), but I just don't *need* that kind of flexibility. And the lack of consistency with Meta keys is frustrating (on my Mac, Carbon Emacs uses command, the terminal uses option, but on other machines I have to fall back on Esc).
I noticed the new Emacs has a built-in spreadsheet, by the way (M-x ses-mode). It's actually pretty cool (the cells are Lisp expressions, and the code is checked for dangerous operations before being excecuted). It's also a sign that maybe Emacs is a little TOO flexible???
Anyway, I'm not sure the point of this post, except that everybody should at least give Emacs a try.
Close your browser!
Dude: "You have to leave now!"
Stallman: "Do you know who I am ? I made EMACS!!"
Dude: "I don't care. I use vi."
All I know about Emacs is that all the Emacs books are in the MAC/Apple section of my local Barnes and Noble.
So it must be a MAC thing, and since I use Windows...
"Live Free or Die." Don't like it? Then keep out of the USA
Is there something that Emacs can't do?
Come with a good editor that doesnt require obscure unlogical keystrokes.
http://saveie6.com/
Look at the official Emacs FAQ.
Short answer, yes it does.
Granted, most of the other editors do this, too. I've been using 'vi' variants for over 20 years, and have currently settled on VIM. Most of them have built-in help for parsing build output, but it just seems so much clunkier than when I watch an EMACS user do it.
What I'd really like is a book or HOWTO that's focused on effective software development using EMACS. The general-purpose "learning" books just don't get into that kind of narrow depth.
Schwab
Editor, A1-AAA AmeriCaptions
I'll have the reviewer know that I use gnus for my email and news reading, and it's perfect for the task. I've still yet to find a program which has as many features, and yet to find one which is accessible over a command-line as well as through a GUI.
I run a shell in emacs (esc-x shell). It works great for searching through reams of command line job output and is slightly easier the piping to a file then searching through it (less, more etc...)
Its better than xterm -sl XYZ (set scroll lines to XYZ)
"Eight Megs And Constantly Swapping"
next to the "Over Eighty Megs And Constantly Swapping" of nowadays heavy-duty IDEs, Emacs is as feather-weigth as vi.
I don't feel like it...
Agreed. I flop caps and ctrl (even in Windows) and have never looked back.
The Sun layout with respect to that is, IMO, vastly superior to the PC layout even w/o the Emacs benefit.
(Of course, I suggest you don't actually get a Sun keyboard, because the location of backspace (no longer at the corner) is an abomination. If you have to use one, may I suggest the following:
(global-set-key "`" 'backward-delete-char-untabify)
(Add that to ~/.emacs) That will fix that braindead decision. I've been known to run a shell from inside Emacs when I'm working on a Sun just so that I can press backspace in the normal location and it will work.
I'd have moded you up but I wanted to take that pot shot at the Sun layout.)
Why buy a book when the solution to Emacs is right here:
get shovel, look shovel, e, e, dig, look, get cpu, look cpu, se, get
food, se, look bear, drop food, look, get key, sw, get bracelet, ne, nw,
nw, ne, ne, ne, e, look bins, w, w, put cpu in computer, type, toukmond,
robert, ls, uncompress paper.o.Z, exit, look paper, type, ftp gamma,
anonymous, toukmond, binary, send lamp.o, send shovel.o, send key.o, send
bracelet.o, send paper.o, quit, rlogin gamma, worms, get lamp, get
shovel, get key, get bracelet, get paper, e, n, e, drop shovel, drop key,
drop bracelet, drop paper, get weight, d, drop weight, nw, u, get
statuette, look statuette, get floppy, se, d, nw, ne, drop floppy, w, s,
e, turn dial clockwise, turn dial clockwise, turn dial clockwise, turn
dial counterclockwise, turn dial counterclockwise, turn dial
counterclockwise, w, n, e, get life, get shovel, get key, get bracelet,
get paper, get floppy, d, nw, u, se, d, nw, nw, s, s, s, s, put diamond
in chute, put bracelet in chute, s, get gold, e, e, s, d, look urinal,
put gold in urinal, flush, n, sleep, d, sw, e, u, dig, look, get
platinum, d, w, ne, u, s, put platinum in urinal, flush, n, d, sw, w, d,
e, get towel, look towel, d, s, s, s, look pc, put floppy in pc, reset, ,
dir, type foo.txt => xxx (combination), exit, n, n, n, n, n, u, look box,
put key in box, u, u, ne, ne, get axe, d, n, w, xxx (combination), cut
cable, exit, get key, e, n, get lamp, get license, get silver, w, put
silver in mail, n, n, e, e, e, e, e, get coins, get egg (in rooms 60 to
78), w, w, w, w, w, s, s, put egg in mail, put coins in mail, n, n, n, n,
e, e, e, e, e, look bus, in, s, s, s, w, w, w, w, w, nw, out, n, get
bone, e, e, get nitric, press switch, n, get glycerine, w, look bone, get
jar, get ruby, s, w, s, in, se, out, e, e, e, e, n, n, put nitric in jar,
put glycerine in jar, drop jar, in, n, n, put ruby in disposal, d, get
amethyst, u, put amethyst in disposal, d, ne, sw, u, u, w, w, s, w, s,
se, s, e, s, w, type, rlogin endgame, drop license, drop bone, drop key,
get diamond, get gold, get platinum, get amethyst, n, n, n, n, get bill,
n, get mona, s, drop bill, drop mona, drop diamond, drop gold, drop
platinum, drop amethyst, s, s, s, s, get silver, get egg, get coins, get
ruby, get bracelet, n, n, n, n, n, drop silver, drop egg, drop coins,
drop ruby, drop bracelet, n, quit,
I'm afraid I can't help you with Emacs Tetris.
Slashdot - Mutual Assured Discussion
Emacs shell mixes up too much command input and output to my taste...
Then most shells (and every program using the readline library) support the Ctrl-R function to search through command history, just like emacs.
For searching through command outputs there are terminal emulators like konsole that provide such functions...
Check man readline you'll be surprised how much of emacs functionality you have in your daily shell!
Aquamacs (Carbon Emacs with settings to make it more Mac-like) cleans up a lot of that stuff. If you map meta to option, you can even use standard Mac keystrokes (command-S -> C-X C-S, command-Q -> C-X C-C, etc.). And SLIME works well under it - Aquamacs + Lisp-in-a-box without Emacs worked for me right out of the box (so to speak).
And, its default font is so much prettier...
To a Lisp hacker, XML is S-expressions in drag.
Emacs has a feature where it can save it's entire state to disk as an executable binary. If you subsequently invoke this binary, Emacs starts up extremely quickly with the restored state, bypassing the usual initialisation and dot-emacs processing. A very neat feature IMO.
Yes, because typing L to go right, K to go up, J for down and H for left is so much more logical than ^F for forward, ^B for backward, ^N for the next line and ^P for the previous line! (I realize non-English speakers will be hosed either way.) Or that a linefeed character has a special status in vi, so you can't just delete it, you have to "join" the lines it separates. Or having to switch constantly between "navigating" and "inserting text," instead of just doing whichever you need to do right away.
This argument has been going on almost as long as the Catholic/Protestant thing. It seems once people get the habit of doing things one way, the other way is "strange" and "counterintuitive." Kind of like every other UI debate.
To answer the GP question: you can get by with about 10-15 basic commands. Open up emacs or xemacs, then type control-H followed by a t (no control). This gets you into the tutorial. Learn the basic navigation, editing and file commands. This will enable you to do all you need to do. Get comfortable with these first, because most of the special modes (like Dired, which lets you navigate directories) use the same keys for analogous operations). Also learn how to do M-x commands, like query-replace. After that, just learn new things a few at a time. The ones that are most useful to whatever you're doing will be the ones you remember.
It also helps to fix your keyboard. Try swapping cntl and caps lock if you're on a PC keyboard (the bane of emacs users), and using Alt as the meta key (great for the meta-based navigation).
stop using Emacs to surf porn then
EMACS is a text mode desktop environment. Sorta like KDE on chemotherapy. Strictly for masochists only.
Oh well, what the hell...
On page 498 the headmaster dies.
There's no reason why learning Emacs has to be intimidating, but it's misleading comments like this that make people believe that they don't understand Emacs.
Do us all a favor and compare the Emacs Manual Table of Contents with the Learning GNU Emacs Table of Contents.
The Emacs manual begins with an encyclopedic glossary of Emacs terms. 17 pages of terms, according to "Print Preview" in Firefox. Afterwards, you get index pages: a list of all the default keys, a list of all the default options (without even a link to a chapter explaining how to tweak an option), a command index (again, no info on how to run a command), a variable index (same deal), and a "concept index" full of links all over the manual. Finally you get to a very abstract section about how to interpret what's on the Screen, but still no information on how to actually use Emacs.
The O'Reilly book begins with "Emacs Basics", an easy-to-follow guide to the beginnings of Emacs. It looks more like the Emacs tutorial in a plain text format.
The Emacs "Manual" is a gigantic man page. It's not a "manual" in the sense that you're supposed to sit down and read it as a first introduction to Emacs. It's not a guide for people to read. It's a reference guide for you to go find information you already knew was there.
I'll admit, the built-in tutorial is a much better introduction, but it leaves you at the novice level. You know how to push the cursor around, but you know *nothing* about how to set options, what a variable is, how to set them, etc. To get from here to there requires hours of reading random info pages to try to find what you're looking for. Nothing like reading a clear manual.
Never recommend that a newbie to Emacs read the Emacs Manual. The Manual is for Intermediate users wishing to become Advanced. The Tutorial is for novices. For those wishing to get to the Intermediate level, this O'Reilly book isn't a half bad choice.
When I moderate, I only use "-1, Overrated". That way, I never get meta-moderated!
nherm@localhost:~$ cat > slashdot_post
back in my days we dindt have those fancy text editors and we where hppy^H^H^H^Hhapy^H^H
^C
nherm@localhost:~$
For those who will fall for this: emacs was written in 1975, vi in 1976. So its very unlikely that emacs was written in response to vi, unless the MIT dudes had a time machine working. And vi was always free, it was written as part of BSD.
My favorite Emacs-specific ergo tip: avoid chording. It's not for nothing that Emacs is so massively configurable. I have:
.emacs (inspired by this.) I used to have a host of other things mapped all over the numeric keypad -- kill, yank, undo -- but I lost them at some point. I should re-create those.
(define-key global-map [f1] 'Control-X-prefix)
(define-key global-map [f2] 'find-file)
(define-key global-map [f3] 'save-buffer)
(define-key global-map [f4] 'kill-buffer)
(define-key global-map [f5] 'switch-to-buffer)
(define-key global-map [f6] 'other-window)
(define-key global-map [f9] 'compile)
in my
Also don't neglect a good setup (good posture, good keyboard, good pointing device), and stretch breaks at least once an hour.
what the hell the /. icon for GNU topics is supposed to be? It looks like a little penis with a silly hat and a security blanket. WTF is it?
"Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
Why I Started:
.emacs configuration from my university days and have transmuted from apollo Domain to SunOS to HP/UX to VMS and finally to Windoze XP with linux slotted in there for home use.
1. I was forced to learn EMACS as the *only* text editor for CPSC200 by a Nazi like professor and his TA henchmen eons ago.
1a. I was a unix newbie, so when told to use emacs and told nothing about vi... guess which one I'll use. Anyways when one is clueless [ESC]:q! is as incomprehensible as [CTRL]x-c. (Anyways cursor movement without using cursor keys sucked with both vi and emacs: the vi "hjkl" movement keys that worked only in certain modes vs. emacs' mnemonic [CTRL]bnpf movement keys... thank {place a deity here, or "DEC" you're athiest or an uber gEEk} for creating VT100 terminals and with it the defacto standard for cursor keycodes, and full screen cursor placement.)
2. I actually used Wordstar before learning emacs, so incomprehensible control key commands were nothing new.
Why I Continued to Use EMACS after CPSC 200 while in University:
1. Unix boxes actually had a control button in a place that made control commands almost ergonomic.
2. One only has so much time to learn other editors when one's busy trying to avoid studying by playing/tweaking MUD's, xtrek, xtank, compiling and trying out beta versions of NCSA Mosaic.
Why I Still Use Emacs Today in an Embedded Development Environment Hosted Off MS Windoze:
1. Same reason I use Linux, Firefox, etc: It's Open Source software so there are alot of gEEks smarter and have more spare time than me developing plugins, extensions, Emacs major modes, etc, etc, so as a result
a) I have access to extensions that would take me forever to write myself, that's assuming I could even come close to implementing such feats of software prowess even if given an infinite number of monkeys to work with,
b) I have the source code for the tool and the extensions, so I can modify and reconfigure them as I like if they don't exactly fit my needs,
c) I don't have to beg to get some purchase order from the accountants to avoid getting the company into trouble with lawsuits for using *my* favourite commercial editor and conversely can use the same editor at home.
2. I have the evolved my
3. It's entertaining watching your coworkers get all pissed off when trying to cut and paste on your Windoze computer because you've swapped the key mapping for CAPS LOCK and CTRL on the Windoze Keyboard and didn't bother to relabel the keys. Note it can get dangerous if your coworkers are near the end of their ropes because everybody's been working way too many hours to meet some artificial deadline that management has decreed upon the peons.
4. Last but not least, Has anybody mentioned the easy macro programming? Without learning a line of lisp, one can create complex macros... and by just learning a smattering of lisp, make macros that will amaze your co-workers (except the unix gods that use only "ed" because they believe that "vi" is not light weight enough, let alone an editor that includes a lisp interpreter and many megabytes of elisp scripts... anyways who needs to see more than one line of text at a time.)
5. Anyways it's gEEky to use Gnu Emacs ([flame suit on] not XEmacs, only weirdo's use that [flame suit off]). What other reason does a nerd need to do anything?
Chapter One: How to exit vi without rebooting the system.
Chapter Two: Learn how to put all your C++ programs and LaTeX documents in a single file.
Chapter Three: How to copy a block of text without having to count the number of lines.
Emacs supports composed characters, so it should be possible to support putting the tone marks in the right place, even if they are saved as seperate characters in the buffer. The problem is that the internationalization features of Emacs are a bit of a black art that very few people know enough about to do anything with.