• Aucun résultat trouvé

REPEATING REQUESTS

Dans le document EMACS TEXT EDITOR USERS' GUIDE (Page 59-65)

SECTION 8 REPEATING REQUESTS

Emacs provides a variety of ways for repeati~g the action of a request, either once or many times. Requests for which it is meaningful and useful to specify "how many times" to do them generally accept a numeric argument. ~ numeric argument is essentially a repetition count, a number that means "repeat this action this number of times." Positive numeric argument generally repeat the request's action in a straightforward manner. Negative numeric arguments generally reverse the action of the request and repeat it; i.e., they cause a request to act like its complement, if it has one.

NU~ERIC ARGU~ENTS

If you want to say, "Go five characters forward," or, "Go four next lines down," you can give the AF and. AN request positive numeric arguments of 5 and 4, respectively.

You give a numeric argument by typing the escape key, ESC, then typing the number you want, and, finally, typing the request. For example, ~b delete six characters, you would type;

ESC 6 AD

(spaces are unnecessary and incorrect, but have been included for legibility.) That is, strike and release the escape key, type a 6, and then type a AD. All the characters disappear at once.

Try it.

Similarly, if you type:

ESC 249 AN

while on the first line of a large file, the screen would fill immediately with lines 240 to 260 (approximately) of the file, with line 250 and the cursor in the middle of the screen (you can verify the line number with AX:). You do not have to watch the cursor step through 250 lines one by one. Experiment with your

8-1 Cf-I27-00

._---_.

file and the AN and Ap requests. Deliberately give a numeric argument too large for your file, and observe what happens.

A negative numeric argument is given by typing ESC -N, where N is the number, before typing the request. With negative arguments, AF goes backward the specified number of characters, AN goes to the Nth previous line, AD acts like II or \177 and deletes N characters to the left of the cursor, etc. ~n argument of ESC -1 or, simply, ESC-, just reverses the action and performs it once. Some requests do not accept negative arguments; you receive a message in the mini buffer stating this if you give them one by mistake.

Requests Accepting Numeric Arguments

Of the requests already learned, the following accept numeric arguments.

AF

"B

"N

"p II

\177

"D

Forward Character Backward Character Next Line

Previous Line Rubout Character Rubout Character Delete Character

"K Kill Lines

"y Yank

"@ Set/Pop the mark

The first seven, when given either a positive or negative numeric argument, perform the action that number of times. The last three act in a special manner, and do not accept negative arguments.

When you give AK a positive numeric argument, it kills that many entire lines, starting at the current point on the current line. Everything killed is put, as one, on the kill ring, and will kill merge with preceding or following killed text as described earlier. Where as ESC 4 "K kills four lines, four "Ks would not, since you generally must type two "Ks to kill one line of text.

When you give Ay a positive numeric argument, it yanks text out of the slot on the kill ring that corresponds to the number

given. As you have seen, a simple " Y request retrieves the

i\.):

latest thing killed, from the first slot. If you want, for

8-2 CH27-00

example, the second latest thing killed (from the second slot), simply give the Ay request a numeric argument of 2 by typing:

ESC 2 Ay

When you give A@ a positive numeric argument, it "pops" the mark off the slot on the mark ring that corresponds to the number given; i.e., it sets the current mark at the position where the saved mark was originally set. If text was deleted from around that position, the current mark is set at the position closest to its former position.

Try all of these requests with numeric arguments until you feel comfortable with them.

Numeric Arguments with Regular Characters

Whether you realized it or not, regular letters and numbers are actually Emacs requests, too. For instance, you know that AD means "delete the character at the cursor." What does an ordinary d mean? What happens when you type an ordinary d, or any number, letter, or punctuation mark? It goes into the buffer and appears on the screen. Printing characters (other than #, @, and \), are said to be self-inserting, because if you type one, ( it inserts itself into the text.

(~.

Giving a positive character causes it to instance, if you type:

ESC 24 Q

numeric argument to insert itself that

a self-inserting many times. For

you see 24 Qs appear on the screen all at once. This is a good way to get lines of dashes, underscores, asterisks, etc.

If ever you type a numeric argument, or are in the middle of typing one, and decide that you did not mean it, type a AG to get you out of it. The reassuring beep verifies that any possible numeric argument has been discarded.

REEXECUTING A REQUEST

"C

After typing a request, you may just want to repeat it once, or to repeat it several times without determining exactly how many times. The AC request, reexecute-command, lets you reexecute the last keystroke request entered. This request is

8-3 cr~27 -00

not especially useful for repeating many of the requests learned

SC) far, since it is just as easy. to retype them as it is to type

"C. Some requests, however, require that you type a sequence of --"'.

keys (e.g., ESC F in the section on word requests); typing " C s _ J prevents you from making an error when repeating these. In

addition, when you use

"c

to re-execute a search request, it does so, reusing the same search string.

MULTIPLE EXECUTIONS OF A REQUEST

"U

A rather special request lets you repeat requests in a couple of different ways. The "u request (multiplier) multiplies the next request 4 times for each use. For example, "U"F moves forward 4 characters; "U"U"F moves forward 16 characters. This request can also be followed by a number, in which case it behaves like ESC followed by a number; "U13"F moves forward 13 characters and "U-13"F moves backward 13 characters. A AU with no following number is considered a positive numeric argument.

Try using "u with various requests that accept numeric arguments (except Ay an A@). If you experiment with it, you will get an ide~ of the approximate "space" covered by 4, 16, or 64

repetitions of the various requests. Then, when something "looks --~\\

about that far," you can type an appropriate number of "Us to get-./") in the right neighborhood, at least.

GOING TO A SPECIFIC LINE NUMBER ESC G

A request that lets you move the cursor to a line specified by its line number is ESC G, go-to-line-number. This request is especially useful when editing ~ultics programs, since many

~ultics tools give diagnostics in terms of line numbers in tQeir input files. If you happen to be positioned on the first line of the buffer, going to the 241st line is easy; just do 240 "Ns by typing:

ESC 240 AN

However, if you are on some other line, it is easier to use ESC G. This request takes a positive numeric argument that is the number of the line to which you want to go. Typing:

ESC 241 ESC G

moves the cursor to the beginning of line 241, line you are currently on. If that line is not

8-4

no matter what on the screen, CH27-00

( i

Emacs selects the appropriate area of the buffer and displays it.

Try it out.

When you are finished, write out your practice file with AXAS or AXAW. For the rest of the tutorial, you can log in or out whenever you want a break, and your file will always be there to read in if you want some ready-prepared text to work with.

Otherwise, you can create new text, and files, if you prefer.

8-5 CH27-00

1\)

))

\

SECTION 9

Dans le document EMACS TEXT EDITOR USERS' GUIDE (Page 59-65)

Documents relatifs