Emacs Progression Path


[Update] This post was originally wrote two years ago. Since then, I have gradually moved most of my personal developing environment from Vim to Emacs. It is the time to rewrite part of it and add the updates.

I was hoping to find something like Python Progression Path or sort of “best practice” for Emacs, because the difference between Vim and Emacs was much larger than I thought. But what I found were either teaching about basic operations such as saving and quiting the editor for people who had access to comupter for the 1st time, or talking about tricks of using Emacs Lisp for the high-end hard-core players… It seemed like I was stuck in the middle, and would stay there for a very long time…

I will sort the contents here as incremental records simulating my Emacs learning process, as well as keeping track of nontrivial materials and thoughts.

Mindset and Starting Point

  • Don’t panic – The Hitchhiker’s Guide to the Galaxy – “it looked insanely complicated , and this was one of the reasons… the other reason was that this device was in fact that most remarkable of all…”
  • To customized the emacs, the starting point is the file ~/.emacs.d/init.el
  • One basic cheat sheet comes in handy. Most of the common keybindings can be easily referred.
  • It’s also much easier to start with a package containing all basic modules. There are several options, which are listed in the following section.
  • To install new package, the easiest way is M-x package-install, and the following operations are similar to surfing the website via lynx. It is even easier to update all installed package: M-x list-packages, U (Mark all package with a newer available version), and x (Download and install all marked packages). More info refers to the Package Menu Buffer.
  • Though I don’t agree with many opinions that Steve Yegge have said, but his claim about Emacs is somewhat correct – “Real engineers use Emacs. You have to be way smart to use it well, and it makes you incredibly powerful if you can master it” – the emacs is highly configurable and can be very powerful, but the user has to be smart simply because the system is so twisted…
  • It’s helpful to know some LISP, for both using Emacs and becoming a better programmer.
  • An off-topic thought. I also agree with Steve’s view about languages, especially – “C++ is dumb, and you can’t write smart systems in a dumb language. Languages shape the world. Dumb languages make for dumb worlds.” =P

Packages

References

Misc

The difference between “killing” and “deleting” is that “killed” text can be reinserted (at any position), whereas “deleted” things cannot be reinserted in this way (you can, however, undo a deletion–see below). Reinsertion of killed text is called “yanking”. Generally, the commands that can remove a lot of text kill the text (they are set up so that you can yank the text), while the commands that remove just one character, or only remove blank lines and spaces, do deletion (so you cannot yank that text). <DEL> and C-d do deletion in the simplest case, with no argument. When given an argument, they kill instead. – This is valid for both vim and emacs.

  • Multiple windows:
    • C-x 0 delete this window
    • C-x 1 delete all other windows
    • C-x 2 vertically split window
    • C-x 3 split window side by side
  • Scoll down the page
    • C-v: page down
    • C-u 8 C-v: scoll down 8 lines
    • C-l: move the current line to the middle of the window
    • C-u 0 C-l: move the current line to the head of the window
  • Getting help
    • C-h c \<Command sequence\>: a very brief description of the command.
    • C-h k \<Command sequence\> displays the documentation of the function, as well as its name
    • C-h t evoke the tutorial of Emacs within the editor.
    • C-h a topics RET searches for commands whose names match the argument topics. The argument can be a keyword, a list of keywords, or a regular expression.
      • C-h i d m emacs RET i topic RET searches for topic in the indices of the Emacs Info manual
      • C-h i d m emacs RET s topic RET searches the text of the manual.
  • Shell History (also Useful for Haskell REPL)
    • M-p (or) C-\<UP\>: Fetch the next earlier old shell command.
    • M-n (or) C-\<DOWN\>: Fetch the next later old shell command.
    • M-r: Begin an incremental regexp search of old shell commands.
    • C-c C-x: Fetch the next subsequent command from the history.
    • C-c .: Fetch one argument from an old shell command.
    • C-c C-l: Display the buffer’s history of shell commands in another window (comint-dynamic-list-input-ring).