Fixing Emacs's Scratch Buffer

Emacs's scratch buffer has lots of problems. This is a controversial issue, because the scratch buffer is one of those things that serves as a identity of emacs. Any criticism on it is like attacking emacs.

But i tell you, dear readers, frankly and directly, this is a emacs cult problem and i've wrote about often. (See: Emacs Undo & Emacs Cult ProblemEmacs Idolization: Have You Read the Emacs Manual From Cover to Cover?)

For a detailed description of scratch buffer problems, see: Emacs: Problems of the Scratch Buffer.

If you are a user of ErgoEmacs Keybinding, the problem is already fixed for you. Simply press 【Ctrl+n】 and new scratch will be created for you, and when you close a modified unsaved buffer, it'll prompt you for save.

In ErgoEmacs keybinding, it's implemented by 2 commands: {new-empty-buffer, close-current-buffer}. The “new-empty-buffer” simply creates a new buffer, titled “untitled”, “untitled<2>”, etc. The code for “close-current-buffer” is a bit more involved. It kills the current buffer, but check if it is modified, but also, add the closed file into a list, so that people can re-open the last closed file, much like web browser's 【Ctrl+Shift+t】. The key is the same. The key to close current file is also the browser standard 【Ctrl+w】.

If you really want to stick with GNU emacs's keys, but want these convenient functions, you can download and copy/modify the code from ErgoEmacs keybinding. Or, J V Toups provided a implementation for persistent scratch buffer. See:

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs