help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get rid of *GNU Emacs* buffer on start-up?


From: Xah Lee
Subject: Re: How to get rid of *GNU Emacs* buffer on start-up?
Date: Thu, 18 Sep 2008 16:50:50 -0700 (PDT)
User-agent: G2/1.0

My previous message (the rot13'd one), is now polished and published
on my website, at:

Suggestions on Emacs's Scratch Buffer
http://xahlee.org/emacs/modernization_scratch_buffer.html

The following is a text version.
----------------------------------

Suggestions on Emacs's Scratch Buffer

Xah Lee, 2008-09

In the article The Modernization of Emacs, i suggested that emacs's
“*scratch*” buffer be removed. In this article, we give some detail
about it.

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

    * It is not useful by 99% of letter writers. If they wanted a
scratch pad, they can open a new document and not save it. This way is
familiar to all software users.
    * The “*scratch*” “buffer” is primarily designed for elisp
programers. (it defaults to lisp mode) Majority of people who use
emacs 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.

Here are few minor reasons:

    * 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.)
    * 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 list it as a top 10 tip in emacs productivity.) Emacs's
“*scratch*” buffer is narrowly geared for elisp editing only,
defaulting to emacs-lisp-mode.
    * Emacs does not provide a user level function to create a new
buffer. It has “Open New file...”, which actually creates a empty file
and immediately prompt user for a file name. This is annoying. Most
apps's New File command actually just create a new buffer, and only
when user save it it becomes a file. When user closes it, it prompts
for saving.

Proposed Fix

I propose that emacs should also add a menu command “New buffer”, with
the keyboard shortcut “Ctrl+n”. Once called, it should create a
scratch buffer titled “untitled”. If one already exists, append
numbers such “untitled 2”. Here are the reasons:

    * The New command is a standard across Mac, Windows, Unix (Linux).
It is familiar to all software users.
    * The Ctrl+n shortcut for New is standard and familiar to all
software users.
    * A New Buffer command (where the corresponding elisp command name
might will be named new-empty-buffer), can supplant completely the
functionality of *scratch* buffer.
    * When users want to have a scratch buffer, he can create it by
simply pressing the shortcut, and when he doesn't want it, he can
simply close it with a standard keystroke Ctrl+w.
    * By adopting the New Buffer and Ctrl+n, users can intuitively
create multiple scratch buffers for any purpose.
    * The name “untitled” is conventional, far more widely understood,
and more general than “scratch”.
    * For those who uses scratch buffer for elisp coding, she can set
the default mode for untitled buffer to emacs lisp mode.
    * Adopting the suggestion would fix several problems for those who
actually use emacs's scratch buffer. (1) emacs no longer mysteriously
respawn the “*scratch*” buffer when user didn't want it. (2) user can
create multiple scratch buffers by just pressing a shortcut. (3) User
can close a scratch buffer and emacs will ask the user if she wants to
save it.

Draft Implementation

The above suggestion is experimentally implemented in my Ergonomic
Keyboard Shortcut Layout For Emacs. The following are the elisp files,
primarily the modern_operations.el:

    * ergonomic_keybinding_dvorak.el.
    * ergonomic_keybinding_qwerty.el.
    * modern_operations.el.

Some detail about the implementation:

    * create-new-buffer will create a new empty buffer named
“untitled”. (this should be added to the menu under “File‣New Buffer”
but i haven't done that yet.)
    * create-new-buffer has standard keyboard shortcut Ctrl+n.
    * elisp command close-current-buffer will close the current
buffer, and if it is a buffer not associated with a file (such as
“untitled”), it'll ask user to save (unless it has no content)
    * close-current-buffer has the standard keyboard shortcut Ctrl+w.
    * close-current-buffer should have menu under “File‣Close”, but it
is not currently done. The existing “File‣Close” menu command in emacs
22.2 calls kill-this-buffer, which has 2 problems. (1) it doesn't have
a shortcut. (2) it doesn't ask users to save a buffer that are not
associated with file (in effect, any text in the buffer is
irreversibly lost immediately). The standard emacs command used to
close a file is kill-buffer (Ctrl+x k). It has a major problem of
prompting user even if the file is already saved.

I have been using the above code daily since late 2007, with
incremental improvement and bug fixes. i'm sure it can use a lot more
polishing for public use. The code is GPL'd, so feel free to grab
pieces for your own use or submit into GNU.

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]