[ Pobierz całość w formacie PDF ]

the minibu er prompts you for a bu er to switch to, and it names a default. The default is the
bu er you'd get if you just hit Return at the prompt, without typing a bu er name. The default
bu er to switch to is always the one most recently left, so that when you are doing a lot of work
between two bu ers, C-x b always defaults to the other" bu er which saves you from having to
type the bu er name . Even if the default bu er is the one you want, however, you should try typing
in its name anyway.
8.4. ENDING AN EDITING SESSION 75
Notice that you get the same sort of completion you got when nding a le: hitting Tab
completes as much of a bu er name as it can, and so on. Whenever you are being prompted for
something in the minibu er, it's a good idea to see if Emacs is doing completion. Taking advantage
of completion whenever it's o ered will save you a lot of typing. Emacs usually does completion
when you are choosing one item out of some prede ned list.
Everything you learned about moving around and editing text in the rst bu er applies to the
new one. Go ahead and change some text in the new bu er, but don't save it i.e. don't type
C-x C-s . Let's assume that you want to discard your changes without saving them in the le. The
command for that is C-x k, which kills" the bu er. Type it now. First you will be asked which
bu er to kill, but the default is the current bu er, and that's almost always the one you want to
kill, so just hit Return . Then you will be asked if you really want to kill the bu er|Emacs always
checks before killing a bu er that has unsaved changes in it. Just type yes" and hit Return , if
you want to kill it.
Go ahead and practice loading in les, modifying them, saving them, and killing their bu ers.
Make sure you don't modify any important system les in a way that will cause trouble3, of course,
but do try to have at least ve bu ers open at once, so you can get the hang of switching between
them.
8.4 Ending an Editing Session
When you are done with your work in Emacs, make sure that all bu ers are saved that should be
saved, and exit Emacs with C-x C-c. Sometimes C-x C-c will ask you a question or two in the
minibu er before it lets you leave|don't be alarmed, just answer them in the obvious ways. If you
think that you might be returning to Emacs later, don't use C-x C-c at all; use C-z, which will
suspend Emacs. You can return to it with the shell command fg" later. This is more e cient than
stopping and starting Emacs multiple times, especially if you have edit the same les again later.
Under X, hitting C-z will merely iconize the window. See the section on iconization in Chapter 5.
This gives you two ways of iconizing Emacs|the normal way your window manager o ers, and C-z.
Remember, when you iconize, a simply fg won't bring the window back|you'll have to use your
window manager.
8.5 The Meta Key
You've already learned about one modi er key" in Emacs, the Control key. There is a second
one, called the Meta key, which is used almost as frequently. However, not all keyboards have their
Meta key in the same place, and some don't have one at all. The rst thing you need to do is nd
where your Meta key is located. Chances are, your keyboard's Alt keys are also Meta keys, if you
are using an IBM PC or other another keyboard that has an Alt key.
3
If you are not the root" user on the machine, you shouldn't be able to hurt the system anyway, but be careful
just the same.
76 CHAPTER 8. EDITING FILES WITH EMACS
The way to test this is to hold down a key that you think might be a Meta key and type x". If
you see a little prompt appear in the minibu er like this: M-x then you've found it. To get rid of
the prompt and go back to your Emacs bu er, type C-g.
If you didn't get a prompt, then there is still one solution. You can use the Escape key as a
Meta key. But instead of holding it down while you type the next letter, you have to tap it and
release it quickly, and then type the letter. This method will work whether or not you have a real
Meta key, so it's the safest way to go. Try tapping Escape and then typing x" now. You should
get that tiny prompt again. Just use C-g to make it go away. C-g is the general way in Emacs to
quit out of something you don't mean to be in. It usually beeps annoyingly at you to let you know
that you have interrupted something, but that's ne, since that's what you intended to do if you
typed C-g!4
The notation M-x is analogous to C-x substitute any character for x" . If you have found a
real Meta key, use that, otherwise just use the Escape key. I will simply write M-x and you'll have
to use your own Meta key.
8.6 Cutting, Pasting, Killing and Yanking
Emacs, like any good editor, allows you to cut and paste blocks of text. In order to do this, you need
a way to de ne the start and end of the block. In Emacs, you do this by setting two locations in the
bu er, known as mark and point. To set the mark, go to the place you want your block to begin
and type C-SPC SPC" means Space , of course . You should see the message Mark set" appear
in the minibu er.5 The mark has now been set at that place. There will be no special highlighting
indicating that fact, but you know where you put it, and that's all that matters.
What about point? Well, it turns out that you've been setting point every time you move the
cursor, because point" just refers to your current location in the bu er. In formal terms, point
is the spot where text would be inserted if you were to type something. By setting the mark, and
then moving to the end of the block of text, you have actually de ned a block of text. This block is
known as the region. The region always means the area between mark and point.
Merely de ning the region does not make it available for pasting. You have to tell Emacs to
copy it in order to be able to paste it. To copy the region, make sure that mark and point are set
correctly, and type M-w. It has now been recorded by Emacs. In order to paste it somewhere else,
just go there and type C-y. This is known as yanking the text into the bu er.
If you want to actually move the text of the region to somewhere else, type C-w instead of M-w.
This will kill the region|all the text inside it will disappear. In fact, it has been saved in the same
way as if you had used M-w. You can yank it back out with C-y, as always. The place Emacs saves
all this text is known as the kill-ring. Some editors call it the clipboard" or the paste bu er".
There's another way to do cutting and pasting: whenever you use C-k to kill to the end of a line,
the killed text is saved in the kill-ring. If you kill more than one line in a row, they are all saved
4
Occasionally, even one C-g isn't enough to persuade Emacs that you really wanted to interrupt what you're doing.
Just keep at it, and Emacs will usually return to a saner mode.
5
On some terminals, C-SPC doesn't work. For these machines, you must use C-@.
8.7. SEARCHING AND REPLACING 77
in the kill-ring together, so that the next yank will paste in all the lines at once. Because of this
feature, it is often faster to use repeated C-k's to kill some text than it is to explicitly set mark and
point and use C-w. However, either way will work. It's really a matter of personal preference how
you do it.
8.7 Searching and Replacing [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • freetocraft.keep.pl
  • Strona Główna
  • Carol Higgins Clark La Collana Maledetta
  • Jerry Ahern Takers 2 River Of Gold
  • 1082. McMahon Barbara Escape Around the World 1 Podróśź w chmurach
  • Bradley, Marion Zimmer Darkover 16 First Age 5 The Winds of Darkover
  • 410. Davis Justine Naucz mnie śźycia
  • Roberts Alison Bez zobowiazan
  • Heather Rainier [Divine Creek Ranch 02 Her Gentle Giant 01] No Regrets (pdf)
  • 075. Mortimer Carole Wywiad z aktorem
  • Catherine Coulter FBI 03 Cel
  • Harp of Winds Maggie Furey(1)
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • stacjefm.opx.pl