Slashdot Mirror


Learning GNU Emacs, 3rd Edition

barryhawkins writes "It's safe to assume that people who are thinking of learning GNU Emacs or improving their Emacs skills are motivated. These people probably know their way around a command prompt, and likely know that Lisp is more than just a speech impediment. They need a book that offers expert advice without wasting time or insulting the intelligence of the reader: Learning GNU Emacs, 3rd Edition is that book." Read on for the rest of Hawkins' review. Learning GNU Emacs, 3rd Edition author Debra Cameron, James Elliott, Marc Loy, Eric Raymond & Bill Rosenblatt pages 534 publisher O'Reilly Publishing rating 9 reviewer Barry Hawkins ISBN 0596006489 summary An intelligent, graded treatment of the landscape of useful Emacs skills and how to internalize them

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.

You can purchase Learning GNU Emacs, 3rd Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

23 of 334 comments (clear)

  1. Re:VI can't we have this thread without someone... by revisitor · · Score: 2, Informative

    There is http://www.delorie.com/gnu/docs/emacs/viper_26.htm l/ for those wanting to return to the one true path (and avoidance of carpal tunnel syndrome).

  2. GNU Emacs Manual Is Excellent by Anonymous Coward · · Score: 5, Informative

    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.

    1. Re:GNU Emacs Manual Is Excellent by grumbel · · Score: 4, Informative

      ### Emacs also comes with a built-in tutorial that is a good interactive introduction to Emacs.

      It not only comes with a tutorial, the editor itself is completly self-documenting.

      Don't know what a key combo means: 'C-h k' then enter the combo
      Don't know what a function means: 'C-h f' then the function name
      Don't know whats available: 'C-h a' to search through all commands
      Wanna know what other commands are hiding behind 'C-x ...': 'C-x C-h' to get a list

      All the stuff you get as results is hyperlinked and Emacs even allows you to let you click through all that docu down the the actual line of source that performs the function. This self-documentation is something that I miss in almost every other app that is around these days and shows that Emacs, for all its problems, is still quite a few years ahead in some areas bejoint other 'state of the art' applications that people use these days.

  3. Re:I've tried to learn emacs to no avail by slim · · Score: 3, Informative

    I'm in exactly the same boat. I don't consider myself to be stupid, but I've made serious efforts to learn Emacs (initially, just as a text editor), using the built in tutorial and previous editions of the O'Reilly book, and none of the keybindings, obscure combinations and long commands stick in my memory.

    Vi wasn't easy to learn either -- but while unintuitive, it is all logical and most of the keybindings have obvious mnemonics.

    I decided to give up on Emacs, and to be honest I've never been given a reason to regret it.

  4. Re:I've tried to learn emacs to no avail by panda · · Score: 4, Informative

    I've been using Emacs for 15 years and started using Emacs before I even knew that vi existed. I use vi when I must, i.e. no Emacs on the server or I'm going in on a slow remote connection, but don't want to use vi for my every day editing. I can do all the basic editing that I need in vi, but for the truly fancy stuff, I feel much more at home in Emacs.

    Automation of repetitive task can go way beyond recorded key strokes once you get a grip on Emacs lisp. This tool has saved me years of work over the time that I've used it.

    The best way to learn Emacs is to just use it. Having this book will help you. I have the first edition now collecting dust on a shelf at home. The help, actually info, is very helpful. There's an interactive tutorial that comes with it, etc.

    My favorite editor, though, must be sed. ;)

    --
    Just be sure to wear the gold uniform when you beam down -- you know what happens when you wear the red one.
  5. IDE vs Emacs vs Jove all have their place by TheNarrator · · Score: 3, Informative

    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.

  6. Refcards.com by bokumo · · Score: 5, Informative

    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!
  7. Tim O'Reilly on vi or emacs by Noksagt · · Score: 4, Informative
    Reference:
    Despite emacs' higher profile as a free software poster child, I think more people actually use vi than emacs. We sell more copies of our vi book than of our emacs book -- almost twice as many each year. This could be because emacs has a free manual that is distributed with it. But I saw a matching statistic at Linux Expo, where O'Reilly sponsors a vi vs. emacs paintball game each year. I happened to check the signup list, and noticed that there were about twice as many people signed up for the vi team as for the emacs team. (Maybe they just like the vi t-shirt -- the team "uniform" -- more than the emacs t-shirt, but I don't think so.
  8. Re:I've tried to learn emacs to no avail by soloport · · Score: 4, Informative
    what's the best way?

    Start with the most basic navigation commands. Learn to use "Ctrl-H, A" and type words in to learn about other commands you may need (e.g. "Ctrl-H, A, page" yields backward-page, forward-page, etc.)

    The most useful thing I've ever done for my productivity, when it comes to Emacs, is to add the following line to my ~/.emacs file:
    (global-set-key "\C-z" 'call-last-kbd-macro)
    So, when I type Ctrl-Z, it doesn't drop me into the shell (very annoying), but instead executes the last macro. Creating a macro is so easy and executing a gazillion iterations of a macro is now that much easier.

    I've tried to switch to IDEs, to Kate (very, very nice), Quanta+ and others. But the power of the easy, fast macro keeps me coming back to Emacs, every time.
  9. Re:I've tried to learn emacs to no avail by Malc · · Score: 2, Informative

    M-x viper-mode

    (Meta or alt key plus x, then type viper-mode when prompterd). Now you have VI keybindings.

  10. Re:Hand hurts after using Emacs all day by mrpotato · · Score: 2, Informative

    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
  11. Re:Reviewed 9 months after publication! by Anonymous Coward · · Score: 2, Informative

    There is a Linux kernel module für emacs to make it start faster.

  12. Re:teco? by HuguesT · · Score: 2, Informative

    Look at the official Emacs FAQ.

    Short answer, yes it does.

  13. emacs's ultimate power.. the shell by acomj · · Score: 4, Informative

    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)

  14. shells vs emacs by tendays · · Score: 2, Informative

    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!

  15. Try Aquamacs Emacs on Mac OS X by alispguru · · Score: 2, Informative

    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).

    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.
  16. Re:EMACS for Development by meowsqueak · · Score: 2, Informative

    If you rebind the control input to the caps lock key (like the old style keyboards) then these 'crazy' keyboard combos become easier.

  17. Vi more logical than emacs? Good one! by Prof.+Pi · · Score: 2, Informative
    Vi wasn't easy to learn either -- but while unintuitive, it is all logical

    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).

  18. Re:I've tried to learn emacs to no avail by An+Onerous+Coward · · Score: 2, Informative

    As a die-hard Emacs fan, I would suggest that you stay with vi. You've got lots of experience with it, it's always available, the number of fans it has would indicate that Emacs can't be all that superior, etc.

    Having said that, if you're still interested in learning Emacs, the best way to do it is cold turkey. You start using Emacs for your daily text-editing activities. All of them. Make yourself a cheat sheet, and stick it on the side of your monitor for easy reference.

    Just try to get the basics at first. Simple navigation, selecting regions, cutting, pasting, and the saving and loading of files should be enough to get you started. Once you're comfortable with those, add in searching, switching between buffers, "autocomplete", find-and-replace, etc. Only add a couple of new features at a time, and give yourself time to make them instinctive before moving on.

    One last thing: Don't touch the mouse. This will help you in the long run, as it will be an incentive to learn to navigate around a buffer. Avoiding the mouse will soon feel very natural.

    My biggest hurdle with Emacs was the fact that I'd never used the Ctrl key, and I kept hitting Shift instead.

    In summary, don't "take a few months off" to learn Emacs in its own right. You'll learn it better by simply using it for whatever project you're already working on. Remember that the learning curve is always steep when compared with sticking to the status quo, but don't be surprised if, once you get up the mountain, you find that you're approximately as productive as you were in vi.

    --

    You want the truthiness? You can't handle the truthiness!

  19. Nice troll! by Some+Random+Username · · Score: 2, Informative

    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.

  20. Re:Hand hurts after using Emacs all day by Zed+Lopez · · Score: 2, Informative

    My favorite Emacs-specific ergo tip: avoid chording. It's not for nothing that Emacs is so massively configurable. I have:

    (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 .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.

    Also don't neglect a good setup (good posture, good keyboard, good pointing device), and stretch breaks at least once an hour.

  21. Re:EMACS for Development by sanjoymahajan · · Score: 2, Informative

    Agreed, rebinding caps lock -> ctrl is a must. And type ctrl-[ instead of escape, since the escape key is usually hard to reach and anyway its position varies from keyboard to keyboard. ctrl-[ is also easier to reach than the alt key is (important for alt-x in Emacs).

  22. Re:charsets for emacs - eg PINYIN by jrumney · · Score: 2, Informative

    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.