[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Log of a newbie /2/16/99
Another thing that is confusing me is that I can save files, but I
want to "close the window" before going on to the next task. Do I
just leave the buffer open? Does it close when I type c-x 1 when I'm
in the next task, ...
This is an interesting question. I think you are confusing a window
with a buffer, a confusion that makes sense if your experience with a
previous editor suggested they are the same. They are not the same;
they are different.
In Emacs, there are three different entities: file, buffer, window.
* A file is stored on a hard disk. It is intended to be permanent,
even if your brother-in-law, working upstairs, inadvertently turns
off all the electricity and your computer shuts down.
* A buffer is a copy of a file in Emacs. It may be modified and
different from the underlying file. Or a buffer may be something
entirely new that has no file that corresponds to it. Buffers, as
such, are not permanent. Emacs automatically saves some buffers
to files every 300 characters or so, so that you can recover a
not-to-ancient version of the buffer after your brother-in-law
turns on the electricity and you reboot your computer.
* A window is what Emacs provides to look at or listen to. A window
shows all or a portion of a buffer. A window is simply an entry
way into a buffer. You, as a user, never deal with files
directly. You always work with buffers that you look at through
So long as you have saved a buffer to its corresponding file, a file
and a buffer remain the same. It does not matter if the buffer (or
only a portion of it) is visible.
To return to your question.
You do not need to close a window before moving on to the next task.
So long as you do not change the buffer displayed in a window, it
does not matter whether it is visible.
However, it is often convenient to make a buffer invisible; this is
called burying a buffer. The buffer is still held in Emacs but is not
displayed in a window.
It is convenient to bury a buffer since you will not unintentionally
switch to it.
When you type `Control-x 1' in the next task, you tell Emacs to display one
main window and one mini-buffer window.
all the other windows (excepting the mini-buffer window) vanish and
the buffers associated with them are buried. This simplifies matters.
You are left with one main window, with one buffer; and you are left
with the mini-buffer with its one-line window. (Minor technical
digression: the one line window showing the mini-buffer is also called
the `echo area'. Also the one-line window can be made larger than one
line as needed.)
Other buffers still exist and can be discovered using the `Control-x
Control-b' command that usually runs the `list-buffers' command (but
which I have rebound on my system to run the
Although I display only one or two windows at a time, plus the
mini-buffer window, I usually have 40 or 50 buffers in my Emacs.
Buffers are ephemeral. Only those you save are kept after Emacs is
You can close a buffer. The jargon is to `kill' the buffer. The
command is `Control-x k' and it removes the buffer from Emacs. After
you have killed a buffer, you no longer can create a window to look
upon the buffer, since the buffer is no longer there. However, any
file that had been associated with the buffer remains. If you saved
the buffer as a file, then the buffer is replicated in the file.
As a practical matter, I save buffers when I finish modifying
them. I kill buffers when I figure I will no longer need them. I
also kill buffers just to simplify my life: when I have too many
buffers in Emacs, I feel it is cluttered and I get lost. For me,
`too many' seems to be a bit more than fifty. Occasionally, when I
am tired, I will simplify even further and reduce the number of
buffers to 10 or 20.
The point is: once you have saved the buffers you want to save with
the `Control-x Control-s' or `Control-x s' commands, you need not
worry about those buffers unless you change them again.
How many buffers you keep is a matter of taste. A good many people I
know prefer to keep fewer than seven, on account they like to remember
them. When you first start a vanilla Emacs you will create three
buffers: the scratch buffer, a *Messages* buffer, and a mini-buffer.
The `list-buffers' command will show only the scratch buffer and the
*Messages* buffer, along with its own *Buffer List* buffer. In the
normal configuration, none of these buffers will ever be saved as files.
When you type the `Control-x s' command, Emacs will only ask you if
you want to save the buffers that it thinks of as those you intend to
be permanent. This does not include ad hoc buffers such as the one
that lists your buffers, or a dired buffer, or the *Message* buffer.
As a practical matter, the Emacs sense of what should be permanent is
correct. When I type `Control-x s', Emacs never fails to ask me if I
want to save as files the buffers that I think should be saved.
I hope this disquisition helps you. It is rather long, and although
the concepts are simple, they are different, I think, from the world
of Microsoft DOS and Windows.
Robert J. Chassell email@example.com
Rattlesnake Enterprises http://www.rattlesnake.com
To unsubscribe or change your address send mail to
"firstname.lastname@example.org" with a subject of "unsubscribe" or "help"
Emacspeak Files |