Subject: bug#1109: closed (Re: bug#11298: 24.0.95; (WISH) Re-look scratch buffers)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 15 Nov 2013 05:07:05 +0000

Your bug report

#11298: Suggestions on emacs's scratch buffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
11298: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11298
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#11298: 24.0.95; (WISH) Re-look scratch buffers
From: Jambunathan K <[email-masked]>
To: [email-masked]
Date: Fri, 15 Nov 2013 10:36:21 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

OP here.  Closed.

>From [email-masked] Tue Oct  7 07:32:35 2008
To: [email-masked]
From: xah lee <[email-masked]>
Subject: Suggestions on emacs's scratch buffer
Date: Tue, 7 Oct 2008 07:31:27 -0700

Hi emacs developers,

Here's a suggestion on emacs scratch buffer i thought might be =20
interesting.

Last month there's a maybe 200 messages flamefeast in gnu.emacs.help =20
on this issue.

I am not sure this suggestion about removing *scratch* buffer is =20
sensible to most emacs developers, but i thought i'd put it in bug =20
database for what's its worth.

The full article of my reasons and suggestions is at:

http://xahlee.org/emacs/modernization_scratch_buffer.html

plain text version follows below my sig.

Thanks for your consideration.

Best,

   Xah
=E2=88=91 http://xahlee.org/

=E2=98=84

---------------------------------------------
Suggestions on Emacs's Scratch Buffer

Xah Lee, 2008-09

In the article The Modernization of Emacs, i suggested that emacs's =20
=E2=80=9C*scratch*=E2=80=9D buffer be removed. In this article, i give =
some detail =20
about it.

In the article, i gave the following as primary reasons that scratch =20
buffer should be removed:

     =E2=80=A2 It is not useful by 99% of letter writers. If they wanted =
a =20
scratch pad, they can open a new document and not save it. This way =20
is familiar to all software users.

     =E2=80=A2 The =E2=80=9C*scratch*=E2=80=9D =E2=80=9Cbuffer=E2=80=9D =
is primarily designed for =20
elisp programers. (it defaults to lisp mode) Majority of people who =20
use emacs are not lisp coders. For lisp coders, they can easily =20
customize their emacs to have a =E2=80=9C*scratch*=E2=80=9D =
=E2=80=9Cbuffer=E2=80=9D.
     =E2=80=A2 The =E2=80=9C*scratch*=E2=80=9D =E2=80=9Cbuffer=E2=80=9D =
is a intrusive idiosyncrasy. =20
It is persistent, cannot be closed (it regenerates). It is foreign to =20=

all programers. This idiosyncrasy is the first thing presented to =20
users, and it persists.

Here are few minor reasons:

     =E2=80=A2 There is no easy, intuitive way to create multiple =
scratch =20
buffers. (it is done by using the switch-to-buffer command (C-x b) =20
and give name that is not one of existing buffers.)

     =E2=80=A2 When the scratch buffer is closed, emacs does not prompt =
user =20
to save it. This easily causes data loss.

     =E2=80=A2 A scratch pad can be very useful not just for temporary =
elisp =20
code but for any scratch notes or programing in other languages. (For =20=

example, well known programer Stevey Yegg in his popular Effective =20
Emacs=E2=86=97 blog list it as a top 10 tip in emacs productivity.) =20
Emacs's =E2=80=9C*scratch*=E2=80=9D buffer is narrowly geared for elisp =
editing =20
only, defaulting to emacs-lisp-mode.

     =E2=80=A2 Emacs does not provide a user level function to create a =
new =20
buffer. It has menu =E2=80=9CFile=E2=80=A3Open file...=E2=80=9D (a =
wrapper to the find-=20
file command), which immediately prompt user for a full file path. =20
This is annoying. Modern apps's New File command actually just create =20=

a new untitled file without prompting, and only when user save it it =20
prompt a file name. If user closes it, it prompts for saving.

Proposed Fix

I propose that emacs should also add a menu command =E2=80=9CNew =
buffer=E2=80=9D, =20
with the keyboard shortcut =E2=80=9CCtrl+n=E2=80=9D. Once called, it =
should create =20
a scratch buffer titled =E2=80=9Cuntitled=E2=80=9D. If one already =
exists, append =20
numbers such =E2=80=9Cuntitled 2=E2=80=9D. Here are the reasons:

     =E2=80=A2 The menu command =E2=80=9CNew=E2=80=9D is a widely =
adopted standard among =20
apps across Mac, Windows, unixes. It is familiar to all software users.

     =E2=80=A2 The Ctrl+n shortcut for New is standard and familiar to =
all =20
software users.

     =E2=80=A2 A New Buffer command (where the corresponding elisp =
command =20
name might be named new-empty-buffer), can completely cover the =20
functionality of emacs's =E2=80=9C*scratch*=E2=80=9D buffer.

     =E2=80=A2 When users want to have a scratch buffer, he can create =
it by =20
simply pressing the shortcut, and when he doesn't want it, he can =20
simply close it with a standard keystroke Ctrl+w.

     =E2=80=A2 By adopting the New Buffer and Ctrl+n, users can =
intuitively =20
create multiple scratch buffers for any purpose.

     =E2=80=A2 The name =E2=80=9Cuntitled=E2=80=9D is conventional, far =
more widely =20
understood, and more general than =E2=80=9Cscratch=E2=80=9D.

     =E2=80=A2 For those who use scratch buffer for elisp coding, she =
can =20
set a preference (e.g. emacs customize feature) so that the new =20
buffer default to emacs-lisp-mode.

     =E2=80=A2 Adopting the suggestion would fix several problems for =
those =20
who actually use emacs's =E2=80=9C*scratch*=E2=80=9D buffer. (1) emacs =
no longer =20
mysteriously spawn a =E2=80=9C*scratch*=E2=80=9D when emacs starts, or =
respawn =20
the =E2=80=9C*scratch*=E2=80=9D buffer when user tries to close all =
buffers. (2) =20
Multiple scratch buffers can be created by a keyboard shortcut. (3) =20
Data lose is prevented because closing a scratch buffer will prompt =20
for save.

Note: the proposed keybinding =E2=80=9CCtrl+n=E2=80=9D and =E2=80=9CCtrl+w=
=E2=80=9D need not =20
be part of this proposal because emacs already use =E2=80=9CCtrl+n=E2=80=9D=
 and =20
=E2=80=9CCtrl+w=E2=80=9D for basic cursor movement and cut. However, it =
could be =20
adapted in conjunction with newly designed Ergonomic Keybinding. (see =20=

below)
Draft Implementation

The above suggestion is experimentally implemented in my Ergonomic =20
Keyboard Shortcut Layout For Emacs. The following are the elisp files.

     =E2=80=A2 ergonomic_keybinding_dvorak.el.
     =E2=80=A2 ergonomic_keybinding_qwerty.el.

Some detail about the implementation:

     =E2=80=A2 create-new-buffer will create a new empty buffer named =20=

=E2=80=9Cuntitled=E2=80=9D. (this should be added to the menu under =
=E2=80=9CFile=E2=80=A3New =20
Buffer=E2=80=9D but i haven't done that yet.)

     =E2=80=A2 create-new-buffer has standard keyboard shortcut Ctrl+n.

     =E2=80=A2 elisp command close-current-buffer will close the current =
=20
buffer, and if it is a buffer not associated with a file (such as =20
=E2=80=9Cuntitled=E2=80=9D), it'll ask user to save (unless it has no =
content)

     =E2=80=A2 close-current-buffer has the standard keyboard shortcut =
Ctrl+w.

     =E2=80=A2 close-current-buffer should have menu under =20
=E2=80=9CFile=E2=80=A3Close=E2=80=9D, but it is not currently done. The =
existing =20
=E2=80=9CFile=E2=80=A3Close=E2=80=9D menu command in emacs 22.2 calls =
kill-this-buffer, =20
which has 2 problems. (1) it doesn't have a shortcut. (2) it doesn't =20
ask users to save a buffer that are not associated with file (in =20
effect, any text in the buffer is irreversibly lost immediately). The =20=

standard emacs command used to close a file is kill-buffer (Ctrl+x =20
k). It has a major problem of prompting user even if the file is =20
already saved.

I have been using the above code daily since late 2007, with =20
incremental improvement and bug fixes. i'm sure it can use a lot more =20=

polishing for public use. The code is GPL'd, so feel free to grab =20
pieces for your own use or submit into GNU.

=E2=98=84