>>> Emacs provides a user level function to create a new buffer. C-x b,
>>> and enter a name of a non-existing buffer.
>>>...
>>> And if I close it without saving,
>>> Emacs prompts me gently -- it doesn't demand a filename, it asks if I
>>> want to save it. And only then, if I say yes, does it prompt for a
>>> filename. How polite.
Xah wrote:
>> what you reported doesn't seems to be the emacs behavior for me.
>
>> For example:
>
>> Type C-x b xyz RET to create a new buffer named xyz.
>
>> Type something in it.
>
>> Now type M-x kill-buffer RET. The buffer will be killed with all
>> content lost.
> I stand corrected: it doesn't prompt to save, since it was never a
> file to begin with. I guess I'm just in the habit of saving when I
> want to.
Thanks for the correction.
> Nevertheless, the original point was that Emacs DOES provide
> a user-level function to create a new buffer. And it also allows you
> to save that buffer as a file -- if you wish.
I don't agree that emacs does provide a user-level function for
creating a new buffer. The 2 practical methods to create a new buffer,
by find-file or switch-to-buffer, are both not designed to create a
new buffer for temp use, and each has serious problems in my opinion.
• There is no easy, intuitive way to create multiple scratch buffers.
(it is done by using the switch-to-buffer command (C-x b) and give
name that is not one of existing buffers.)
• Emacs does not provide a user level function to create a new buffer.
It has “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 only when user save it it prompt a file name.
If user closes it, it prompts for saving.
In summary: the problem with find-file is that it promps user to enter
a file name upfront. The problem with switch-to-buffer is that it
doesn't promp to save when user closes it. In both, the functions are
simply not designed for creating a new temp buffer.
-------------------------
But now suppose for a moment that find-file and switch-to-buffer are
very good for creating temp buffers. Isn't that more reason to get rid
of “*scratch*”?
original article
http://xahlee.org/emacs/modernization_scratch_buffer.html
Xah
∑
http://xahlee.org/
☄