Emacs: Problems of the Scratch Buffer
Xah Lee, 2008-09, …, 2011-04-15
In the article The Modernization of Emacs, i suggested that emacs's “*scratch*” buffer be removed. In this article, i give some detail about it.
Scratch Buffer Not Useful to Most People
Here are reasons that the scratch buffer is not useful to most people:
- It is not useful for 99% of emacs users. If people wanted a scratch pad, they can open a new document and not save it. This way is familiar to all software users. This is typically done by pressing 【Ctrl+n】, a keystroke far easier than in emacs to switch to scratch buffer 【Ctrl+x b *scr Tab Enter】
- The “*scratch*” “buffer” is primarily designed for emacs lisp programers. (it defaults to lisp-interaction-mode.) Vast majority of emacs users are not lisp coders. For lisp coders, they can easily customize their emacs to have a “*scratch*” “buffer”.
- The “*scratch*” “buffer” is a intrusive idiosyncrasy. It is persistent, cannot be closed (it regenerates). It is foreign to all programers. This idiosyncrasy is the first thing presented to users, and it persists.
Scratch Buffer Problems
Here are reasons that a alternative to “*scratch*” “buffer” is more useful:
- There is no easy, intuitive way to create multiple scratch buffers. (it is done by using the switch-to-buffer command 【Ctrl+x b】 and give a name that is not one of existing buffers.)
- When the scratch buffer is closed, emacs does not prompt user to save it. This easily causes data loss.
- A scratch pad can be very useful not just for temporary elisp code but for any scratch notes or programing in other languages. (For example, well known programer Stevey Yegg in his popular
Effective Emacs blog, considers creating new temp buffer as a top 10 tip in emacs productivity.)
- Emacs does not provide a user level function to create a new buffer. It has menu 〖File▸Open file…〗 (a wrapper to the find-file command), which immediately prompt user for a full file path. This is annoying. Modern apps's New File command actually just create a new untitled file without prompting, and prompt only when user wants to save it. If user closes it, it prompts for saving.
Proposed Fix: Adding a “new-buffer” Command
I propose that emacs should add a menu command “new-buffer”. Once called, it should create a empty buffer titled “untitled”. If one already exists, append numbers such “untitled 2”. This would be similar to most editor's 〖New Document〗 command. Here are the reasons:
- The menu command “New” is a widely adopted standard among apps across Mac, Windows, Linux. It is familiar to all software users.
- A “new-buffer” command can completely cover the functionality of emacs's “*scratch*” buffer.
- When users want to have a scratch buffer, he can just call “new-buffer”, or use the menu, or use a hotkey provided by emacs.
- The name “untitled” is conventional, widely understood, than “scratch”.
- For those who use scratch buffer for elisp coding, she can set a preference so that the new buffer default to lisp-interaction-mode as with scratch buffer.
Adopting the suggestion would fix several problems for those who actually use emacs's “*scratch*” buffer. ① emacs no longer mysteriously spawn a “*scratch*” when emacs starts, or respawn the “*scratch*” buffer when user tries to close all buffers. ② Multiple scratch buffers can be created by a keyboard shortcut. ③ Data lose is prevented because closing a modified scratch buffer will prompt for save.
Draft Implementation
The above suggestion is implemented in
ErgoEmacs Keybinding, where you simply press 【Ctrl+n】 to create a new buffer.
The original thread of this discussion, which turned into a flame feast, is here:
Newsgroups: gnu.emacs.help
From: Xah Lee.
Date: Tue, 16 Sep 2008 13:57:59 -0700 (PDT)
Subject: Re: How to get rid of *GNU Emacs* buffer on start-up?
Source groups.google.com
2012-01-12 Thanks to Tom Davey for a correction.
blog comments powered by