This sounds intriguing. Do you have a pointer to something I could read that might expand on what you're saying here? (Aside from the emacs source.)
Amusing coincidence: the only Pratchet book I've read is The Fifth Elephant.
Sure, I understand that there is this abstraction of a Buffer. But it's quite abstract. I'd love to know what's happening under the hood.
I think a blog post that even gave a 37signals-blog-post-sized expansion of the grandparent's comment would probably be frontpaged on HN.
- Nightwatch: Great idea, fantastically written
- Going Postal: Great book for everybody who reads HN. Great characters, storyline, and fantasy meets hacking.
The definition is really simple: a buffer is just a bunch of text from some unknown source, but in fact it is a very powerful abstraction, for two reasons. First, every time you do something in Emacs when simply editing files, you are really executing emacslisp functions on the buffer that is currently displayed. A lot of things you learn in Emacs can be used in three ways: interactively in editing sessions, when automating editing tasks with emacslisp, and finally when doing programming in general, even when it has nothing to do with editing files.
Second, a buffer can represent anything, it can of course contain the text of a file, but also of only fragments of a file, or a directory file listing, and, what's really great, Emacs binds TCP/FTP/HTTP/... network connections and external processes to buffers as well, allowing asynchronous streaming of incoming data into buffers, so that a emacslisp callback is called every time new text arrives from the process or socket, you can transform it as you wish and insert into the buffer the part to be shown to the user or kept for future processing. Then there are lisp primitives implemented in C like save-excursion which let you execute functions on buffer off-screen, so the same commands that are used for editing can be used for processing HTTP requests or grep output without the user noticing the cursor jumping back and forth or anything of this kind. So, when I am processing HTTP requests in Emacs, I use the same commands I sometimes use in interactive editing sessions, for example I can use re-search-forward to check if the headers were sent completely already and to get number of bytes they contain (the location in the buffer of the end of the headers, in other words). A lot of the weird emacs word like point, mark etc. that seem like anachronistic words for interface elements really are powerful abstractions that apply as much to programming as to the interactive editing.
Then there is a lot of other stuff that makes this yet more powerful, you can have buffer-local variables, timers that check buffer input periodically, transaction queues for those asynchronous processes, modes that define buffer-specific key-bindings, menus and behaviours etc., it goes on an on. It's a lot like node.js or other asynchronous networking stacks. There is also lot of magic that makes all this work concurrently without Emacs having implemented threads, and that makes it not interfere with the user interface.
A lot of the cool things Emacs does follows from this architecture, like the SLIME package for interacting with Common Lisp interpreters (local or remote), Dired for editing directory contents, Tramp for editing files on remote servers, Comint for running interactive processes of various kind inside Emacs etc. It's a really great lesson in how naturally features flow out of powerful design ideas.
As for resources, I learnt by reading the GNU Emacs Lisp Reference [1], and have done a lot of M-x describe-function and source code reading in the process of writing some elisp more sophisticated than just small editing helpers. E.g. the process stuff is described here:
http://www.gnu.org/software/emacs/manual/html_node/elisp/Pro...
1) intial emacs setup: it feels really tricky to just get basic editor sanity configured (auto-indent, syntax highlighting, etc.)
2) I worry that by using evil mode, I lose out on a lot of the goodness of emacs major and minor mode's. Do you remap everything to be more vi-ish for each mode that you use? I guess that is fine but the transition just seems daunting.
I haven't seen any lost functionality by using evil; modes that define bindings continue to work, and the usual C-x/C-c/M-x/whatever works fine with evil. There is the odd major mode that doesn't work with evil out of the box (usually if it redefines j/k) but most have no problems. You can still use most (all?) regular Emacs movement commands with evil as well.
IMHO, Evil Mode makes to use emacs doable OTOH, the fact that there are so much extensions and possibilities under the hood makes to use emacs mandatory! :P
I'm still trying to figure out the emacs portions of emacs. I don't have the work flow quite right; things like buffer management, saving sessions, shell in emacs, etc.
1.http://www.emacswiki.org/emacs/InteractivelyDoThings
2. http://www.emacswiki.org/emacs/DeskTop
3. For 3 I just use built in shell-mode, but what is really neat is saving your shell session to a file "C-x C-w" every so often. Then if you reboot or crash or whatever, emacs-desktop will bring back all your open files and all your shells. I usually have 3, regular bash, a sql session, and maybe an ssh session to somewhere, all with a full record of what I've done, sometimes going back months.