source: branches/acl2-egc/source/cocoa-ide/hemlock/doc/user/commands.mss

Last change on this file was 6, checked in by Gary Byers, 21 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 36.1 KB
Line 
1@comment{-*- Dictionary: hem; Mode: spell; Package: Hemlock -*-}
2@chap[Basic Commands]
3@section[Motion Commands]
4
5@index[commands, basic]@index[motion]There is a fairly small number of
6basic commands for moving around in the buffer. While there are many other
7more complex motion commands, these are by far the most commonly used and
8the easiest to learn.
9
10@defcom[com "Forward Character", bind (C-f, Rightarrow)]
11@defcom1[com "Backward Character", bind (C-b, Leftarrow)]
12@index[character, motion]
13@hid[Forward Character] moves the point forward by one character. If a prefix
14argument is supplied, then the point is moved by that many characters.
15@hid[Backward Character] is identical, except that it moves the point
16backwards.
17@enddefcom
18
19@defcom[com "Forward Word", bind {M-f}]
20@defcom1[com "Backward Word", bind {M-b}]
21@index[word, motion]These commands move the point forward and backward
22over words. The point is always left between the last word and first
23non-word character in the direction of motion. This means that after moving
24backward the cursor appears on the first character of the word, while after
25moving forward, the cursor appears on the delimiting character. Supplying
26a prefix argument moves the point by that many words.
27@enddefcom
28
29@defcom[com "Next Line", bind (C-n, Downarrow)]
30@defcom1[com "Previous Line", bind (C-p, Uparrow)]
31@defcom1[com "Goto Absolute Line"]
32@index[line, motion]
33@hid[Next Line] and @hid[Previous Line] move to adjacent lines, while remaining
34the same distance within a line. Note that this motion is by logical lines,
35each of which may take up many lines on the screen if it wraps. If a prefix
36argument is supplied, then the point is moved by that many lines.
37
38The position within the line at the start is recorded, and each successive
39use of @binding[C-p] or @binding[C-n] attempts to move the point to that
40position on the new line. If it is not possible to move to the recorded
41position because the line is shorter, then the point is left at the end of
42the line.
43
44@hid[Goto Absolute Line] moves to the indicated line, as if you counted them
45starting at the beginning of the buffer with number one. If the user supplies
46a prefix argument, it is the line number; otherwise, @Hemlock prompts the user
47for the line.
48@enddefcom
49
50@defcom[com "End of Line", bind {C-e}]
51@defcom1[com "Beginning of Line", bind {C-a}]
52@hid[End of Line] moves the point to the end of the current line, while
53@hid[Beginning of Line] moves to the beginning. If a prefix argument is
54supplied, then the point is moved to the end or beginning of the line that
55many lines below the current one.
56@enddefcom
57
58@defcom[com "Scroll Window Down", bind {C-v}]
59@defcom1[com "Scroll Window Up", bind {M-v}]
60@index[scrolling]
61@hid[Scroll Window Down] moves forward in the buffer by one screenful of text,
62the exact amount being determined by the size of the window. If a prefix
63argument is supplied, then this scrolls the screen that many lines. When this
64action scrolls the line with the point off the screen, it this command moves
65the point to the vertical center of the window. @hid[Scroll Window Up] is
66identical to @hid[Scroll Window Down], except that it moves backwards.
67@enddefcom
68
69@defhvar[var "Scroll Overlap", val {2}]
70This variable is used by @hid[Scroll Window Down] and @hid[Scroll Window Up] to
71determine the number of lines by which the new and old screen should overlap.
72@enddefhvar
73
74@defcom[com "End of Buffer", bind (M-<)]
75@defcom1[com "Beginning of Buffer", bind (@bf[M->])]
76These commands are used to conveniently get to the very beginning and end of the
77text in a buffer. Before the point is moved, its position is saved by
78pushing it on the mark stack (see page @pageref[marks]).
79@enddefcom
80
81@defcom[com "Top of Window", bind (M-,)]
82@defcom1[com "Bottom of Window", bind (M-.)]
83@index[window, motion]@hid[Top of Window] moves the point to the beginning of
84the first line displayed in the current window. @hid[Bottom of Window] moves
85to the beginning of the last line displayed.
86@enddefcom
87
88
89@section[The Mark and The Region]
90
91@label[marks]@index[marks]@index[region]@index[selection]Each buffer has a
92distinguished position known as the @i[mark]. The mark initially points to the
93beginning of the buffer. The area between the mark and the point is known as
94the @i[region]. Many @hemlock commands which manipulate large pieces of text
95use the text in the region. To use these commands, one must first use some
96command to mark the region.
97
98@index[active regions]Although the mark is always pointing somewhere (initially
99to the beginning of the buffer), region commands insist that the region be made
100@i[active] before it can be used. This prevents accidental use of a region
101command from mysteriously mangling large amounts of text.
102
103@defhvar[var "Active Regions Enabled", val {t}]
104When this variable is true, region commands beep unless the region is active.
105This may be set to @false for more traditional @emacs region semantics.
106@enddefhvar
107
108Once a marking command makes the region active, it remains active until:
109@begin[itemize]
110a command uses the region,
111
112a command modifies the buffer,
113
114a command changes the current window or buffer,
115
116a command signals an editor error,
117
118or the user types @binding[C-g].
119@end[itemize]
120Motion commands have the effect of redefining the region, since they move the
121point and leave the region active.
122
123@index[ephemerally active regions]Commands that insert a large chunk of
124text into the buffer usually set an @i[ephemerally active] region around
125the inserted text. An ephemerally active region is always deactivated by
126the next command, regardless of the kind of command. The ephemerally
127active region allows an immediately following region command to manipulate
128the inserted text, but doesn't persist annoyingly. This is also very
129useful with active region highlighting, since it visibly marks the inserted
130text.
131
132
133@defhvar[var "Highlight Active Region", val {t}]
134@defhvar1[var "Active Region Highlighting Font", val {nil}]
135When @hid[Highlight Active Region] is true, @hemlock displays the text in the
136region in a different font whenever the region is active. This provides a
137visible indication of what text will be manipulated by a region command.
138Active region highlighting is only supported under @windows.
139
140@hid[Active Region Highlighting Font] is the name of the font to use for active
141region highlighting. If unspecified, @hemlock uses an underline font.
142@enddefhvar
143
144
145@defcom[com "Set/Pop Mark", bind (C-@@)]
146This command moves the mark to the point (saving the old mark on the mark
147stack) and activates the region. After using this command to mark one end of
148the region, use motion commands to move to the other end, then do the region
149command. This is the traditional @emacs marking command; when running under a
150windowing system with mouse support, it is usually easier to use the mouse with
151the @comref[Point to Here] and @comref[Generic Pointer Up].
152
153For historical reasons, the prefix argument causes this command to do things
154that are distinct commands in @Hemlock. A prefix argument of four does
155@hid[Pop and Goto Mark], and a prefix argument of @f[16] does
156@hid[Pop Mark].
157@enddefcom
158
159@defcom[com "Mark Whole Buffer", bind (C-x h)]
160@defcom1[com "Mark to Beginning of Buffer", bind (C-<)]
161@defcom1[com "Mark to End of Buffer", bind (C->)]
162@hid[Mark Whole Buffer] sets the region around the whole buffer, with the point
163at the beginning and the mark at the end. If a prefix argument is supplied,
164then the mark is put at the beginning and the point at the end. The mark is
165pushed on the mark stack beforehand, so popping the stack twice will restore
166it.
167
168@hid[Mark to Beginning of Buffer] sets the current region from point to the
169beginning of the buffer.
170
171@hid[Mark to End of Buffer] sets the current region from the end of the buffer
172to point.
173@enddefcom
174
175@defcom[com "Activate Region", bind (C-x C-Space, C-x C-@@)]
176This command makes the region active, using whatever the current position of
177the mark happens to be. This is useful primarily when the region is
178accidentally deactivated.
179@enddefcom
180
181
182@subsection[The Mark Stack]
183
184@index[mark stack]As was hinted at earlier, each buffer has a @i[mark stack],
185providing a history of positions in that buffer. The current mark is the mark
186on the top of the stack; earlier values are recovered by popping the stack.
187Since commands that move a long distance save the old position on the mark
188stack, the mark stack commands are useful for jumping to interesting places in
189a buffer without having to do a search.
190
191@defcom[com "Pop Mark", bind (C-M-Space)]
192@defcom1[com "Pop and Goto Mark", bind (M-@@, M-Space)]
193@hid[Pop Mark] pops the mark stack, restoring the current mark to the next most
194recent value. @hid[Pop and Goto Mark] also pops the mark stack, but instead of
195discarding the current mark, it moves the point to that position. Both
196commands deactivate the region.
197@enddefcom
198
199@defcom[com "Exchange Point and Mark", bind (C-x C-x)]
200This command interchanges the position of the point and the mark, thus moving
201to where the mark was, and leaving the mark where the point was. This command
202can be used to switch between two positions in a buffer, since repeating it
203undoes its effect. The old mark isn't pushed on the mark stack, since it is
204saved in the point.
205@enddefcom
206
207
208@subsection[Using The Mouse]
209
210@index[mouse]It can be convenient to use the mouse to point to positions in
211text, especially when moving large distances. @hemlock defines several
212commands for using the mouse. These commands can only be used when running
213under @windows (see page @pageref[using-x].)
214
215@defcom[com "Here to Top of Window", bind (Rightdown)]
216@defcom1[com "Top Line to Here", bind (Leftdown)]
217@index[window, motion]@hid[Here to Top of Window] scrolls the window so as to
218move the line which is under the mouse cursor to the top of the window. This
219has the effect of moving forward in the buffer by the distance from the top of
220the window to the mouse cursor. @hid[Top Line to Here] is the inverse
221operation, it scrolls backward, moving current the top line underneath the
222mouse.
223
224If the mouse is near the left edge of a window, then these commands do smooth
225scrolling. @hid[Here To Top of Window] repeatedly scrolls the window up by one
226line until the mouse button is released. Similarly, @hid[Top Line to Here]
227smoothly scrolls down.
228@enddefcom
229
230@defcom[com "Point to Here", bind (Middledown, S-Leftdown)]
231This command moves the point to the position of the mouse, changing to a
232different window if necessary.
233
234When used in a window's modeline, this moves the point of the window's buffer
235to the position within the file that is the same percentage, start to end, as
236the horizontal position of the mouse within the modeline. This also makes this
237window current if necessary.
238
239This command supplies a function @hid[Generic Pointer Up] invokes if it runs
240without any intervening generic pointer up predecessors executing. If the
241position of the pointer is different than the current point when the user
242invokes @hid[Generic Pointer Up], then this function pushes a buffer mark at
243point and moves point to the pointer's position. This allows the user to mark
244off a region with the mouse.
245@enddefcom
246
247@defcom[com "Generic Pointer Up", bind (Middleup, S-Leftup)]
248Other commands determine this command's action by supplying functions that
249this command invokes. The following built-in commands supply the following
250generic up actions:
251@Begin[Description]
252@hid[Point to Here]@\
253 When the position of the pointer is different than the current point, the
254action pushes a buffer mark at point and moves point to the pointer's position.
255
256@hid[Bufed Goto and Quit]@\
257 The action is a no-op.
258@End[Description]
259@enddefcom
260
261@defcom[com "Insert Kill Buffer", bind (S-Rightdown)]
262This command is a combination of @hid[Point to Here] and @comref[Un-Kill]. It
263moves the point to the mouse location and inserts the most recently killed
264text.
265@enddefcom
266
267
268@section[Modification Commands]
269@index[commands, modification]
270
271There is a wide variety of basic text-modification commands, but once again the
272simplest ones are the most often used.
273
274@subsection[Inserting Characters]
275@index[character, insertion]
276@index[insertion, character]
277
278In @hemlock, you can insert characters with graphic representations by typing
279the corresponding key-event which you normally generate with the obvious
280keyboard key. You can only insert characters whose codes correspond to ASCII
281codes. To insert those without graphic representations, use @hid[Quoted
282Insert].
283
284@defcom[com "Self Insert"]
285@hid[Self Insert] inserts into the buffer the character corresponding to the
286key-event typed to invoke the command. This command is normally bound to all
287such key-events @binding[Space]. If a prefix argument is supplied, then this
288inserts the character that many times.
289@enddefcom
290
291@defcom[com "New Line", bind (Return)]
292This command, which has roughly the same effect as inserting a @bf[Newline],
293is used to move onto a new blank line. If there are at least two blank
294lines beneath the current one then @binding[Return] cleans off any
295whitespace on the next line and uses it, instead of inserting a newline.
296This behavior is desirable when inserting in the middle of text, because
297the bottom half of the screen does not scroll down each time @hid[New Line]
298is used.
299@enddefcom
300
301@defcom[com "Quoted Insert", bind {C-q}]
302Many key-events have corresponding ASCII characters, but these key-events are
303bound to commands other than @hid[Self Insert]. Sometimes they are otherwise
304encumbered such as with @binding[C-g]. @hid[Quoted Insert] prompts for a
305key-event, without any command interpretation semantics, and inserts the
306corresponding character. If the appropriate character has some code other than
307an ASCII code, this will beep and abort the command. A common use for this
308command is inserting a @bf[Formfeed] by typing @binding[C-q C-l]. If a prefix
309argument is supplied, then the character is inserted that many times.
310@enddefcom
311
312@defcom[com "Open Line", bind {C-o}]
313This command inserts a newline into the buffer without moving the point.
314This command may also be given a prefix argument to insert a number of
315newlines, thus opening up some room to work in the middle of a screen of
316text. See also @comref[Delete Blank Lines].
317@enddefcom
318
319
320@subsection[Deleting Characters]
321@index[deletion, character]
322@index[character, deletion]
323There are a number of commands for deleting characters as well.
324
325@defhvar[var "Character Deletion Threshold", val {5}]
326If more than this many characters are deleted by a character deletion command,
327then the deleted text is placed in the kill ring.
328@enddefhvar
329
330@defcom[com "Delete Next Character", bind {C-d}]
331@defcom1[com "Delete Previous Character", bind (Delete, Backspace)]
332@hid[Delete Next Character] deletes the character immediately following the
333point, that is, the character which appears under the cursor. When given a
334prefix argument, @binding[C-d] deletes that many characters after the
335point. @hid[Delete Previous Character] is identical, except that it
336deletes characters before the point.
337@enddefcom
338
339@defcom[com "Delete Previous Character Expanding Tabs"]
340@hid[Delete Previous Character Expanding Tabs] is identical to
341@hid[Delete Previous Character], except that it treats tabs as the
342equivalent number of spaces. Various language modes that use tabs for
343indentation bind @binding[Delete] to this command.
344@enddefcom
345
346
347@subsection[Killing and Deleting]
348
349@index[killing]@index[cutting]@index[pasting]@index[kill ring]@hemlock has many
350commands which kill text. Killing is a variety of deletion which saves the
351deleted text for later retrieval. The killed text is saved in a ring buffer
352known as the @i[kill ring]. Killing has two main advantages over deletion:
353@begin[enumerate]
354If text is accidentally killed, a not uncommon occurrence, then it can be
355restored.
356
357Text can be moved from one place to another by killing it and then
358restoring it in the new location.
359@end[enumerate]
360
361Killing is not the same as deleting. When a command is said to delete
362text, the text is permanently gone and is not pushed on the kill ring.
363Commands which delete text generally only delete things of little
364importance, such as single characters or whitespace.
365
366@subsection[Kill Ring Manipulation]
367@defcom[com "Un-Kill", bind {C-y}]
368@index[kill ring, manipulation]This command "yanks" back the most
369recently killed piece of text, leaving the mark before the inserted text
370and the point after. If a prefix argument is supplied, then the text that
371distance back in the kill ring is yanked.
372@enddefcom
373
374@defcom[com "Rotate Kill Ring", bind {M-y}]
375This command rotates the kill ring forward, replacing the most recently
376yanked text with the next most recent text in the kill ring. @binding[M-y]
377may only be used immediately after a use of @binding[C-y] or a previous
378use of @binding[M-y]. This command is used to step back through the text
379in the kill ring if the desired text was not the most recently killed, and
380thus could not be retrieved directly with a @binding[C-y]. If a prefix
381argument is supplied, then the kill ring is rotated that many times.
382@enddefcom
383
384@defcom[com "Kill Region", bind {C-w}]
385@index[region, killing]This command kills the text between the point and
386mark, pushing it onto the kill ring. This command is usually the best way
387to move or remove large quantities of text.
388@enddefcom
389
390@defcom[com "Save Region", bind {M-w}]
391This command pushes the text in the region on the kill ring, but doesn't
392actually kill it, giving an effect similar to typing @binding[C-w C-y].
393This command is useful for duplicating large pieces of text.
394@enddefcom
395
396@subsection[Killing Commands]
397
398@index[commands, killing]Most commands which kill text append into the
399kill ring, meaning that consecutive uses of killing commands will insert
400all text killed into the top entry in the kill ring. This allows large
401pieces of text to be killed by repeatedly using a killing command.
402
403@defcom[com "Kill Line", bind {C-k}]
404@defcom1[com "Backward Kill Line"]
405@index[line, killing]@hid[Kill Line] kills the text from the point to the
406end of the current line, deleting the line if it is empty. If a prefix
407argument is supplied, then that many lines are killed. Note that a prefix
408argument is not the same as a repeat count.
409
410@hid[Backward Kill Line] is similar, except that it kills from the point to the
411beginning of the line. If it is called at the beginning of the line, it kills
412the newline and any trailing whitespace on the previous line. With a prefix
413argument, this command is the same as @hid[Kill Line] with a negated argument.
414@enddefcom
415
416@defcom[com "Kill Next Word", bind {M-d}]
417@defcom1[com "Kill Previous Word", bind (M-Backspace, M-Delete)]
418@index[word, killing]@hid[Kill Next Word] kills from the point to the end
419of the current or next word. If a prefix argument is supplied, then that
420many words are killed. @hid[Kill Previous Word] is identical, except that
421it kills backward.
422@enddefcom
423
424@subsection[Case Modification Commands]
425
426@index[case modification]@hemlock provides a few case modification
427commands, which are often useful for correcting typos.
428
429@defcom[com "Capitalize Word", bind {M-c}]
430@defcom1[com "Lowercase Word", bind {M-l}]
431@defcom1[com "Uppercase Word", bind {M-u}]
432@index[word, case modification]These commands modify the case of the
433characters from the point to the end of the current or next word, leaving
434the point after the end of the word affected. A positive prefix argument
435modifies that many words, moving forward. A negative prefix argument
436modifies that many words before the point, but leaves the point unmoved.
437@enddefcom
438
439@defcom[com "Lowercase Region", bind (C-x C-l)]
440@defcom1[com "Uppercase Region", bind (C-x C-u)]
441@index[region, case modification]These commands case-fold the text in the
442region. Since these commands can damage large amounts of text, they ask for
443confirmation before modifying large regions and can be undone with @hid[Undo].
444@enddefcom
445
446@subsection[Transposition Commands]
447
448@index[transposition]@index[commands, transposition]@hemlock provides a
449number of transposition commands. A transposition command swaps the
450"things" before and after the point and moves forward one "thing". Just
451how a "thing" is defined depends on the particular transposition command.
452Transposition commands, particularly
453@hid[Transpose Characters] and @hid[Transpose Words], are useful for
454correcting typos. More obscure transposition commands can be used to amaze
455your friends and demonstrate your immense knowledge of exotic @emacs
456commands.
457
458To the uninitiated, the behavior of transposition commands may seem mysterious;
459this has led some implementors to attempt to improve the definition of
460transposition, but right-thinking people will accept no substitutes. The
461@emacs transposition definition used in @hemlock has two useful properties:
462@begin[enumerate]
463Repeated applications of a transposition command have a useful effect. The
464way to visualize this effect is that each use of the transposition command
465drags the previous thing over the next thing. It is possible to correct
466double transpositions easily using @hid[Transpose Characters].
467
468Transposition commands move backward with a negative prefix argument, thus
469undoing the effect of the equivalent positive argument.
470@end[enumerate]
471
472@defcom[com "Transpose Characters", bind {C-t}]
473@index[character, transposition]This command exchanges the characters on
474either side of the point and moves forward, unless at the end of a line, in
475which case it transposes the previous two characters without moving.
476@enddefcom
477
478@defcom[com "Transpose Lines", bind (C-x C-t)]
479@index[line, transposition]This command transposes the previous and
480current line, moving down to the next line. With a zero argument, it
481transposes the current line and the line the mark is on.
482@enddefcom
483
484@defcom[com "Transpose Words", bind {M-t}]
485@index[word, transposition]This command transposes the previous word and
486the current or next word.
487@enddefcom
488
489
490@defcom[com "Transpose Regions", bind (C-x t)]
491This command transposes two regions with endpoints defined by the mark stack
492and point. To use this command, place three marks (in order) at the start and
493end of the first region, and at the start of the second region, then place the
494point at the end of the second region. Unlike the other transposition
495commands, a second use will simply undo the effect of the first use, and to do
496even this, you must reactivate the current region.
497@enddefcom
498
499
500@subsection[Whitespace Manipulation]
501These commands change the amount of space between words. See also the
502indentation commands in section @ref[indentation].
503
504@defcom[com "Just One Space", bind (M-|)]
505@index[whitespace, manipulation]@index[indentation, manipulation]This
506command deletes all whitespace characters before and after the point and then
507inserts one space. If a prefix argument is supplied, then that number of
508spaces is inserted.
509@enddefcom
510
511@defcom[com "Delete Horizontal Space", bind (M-\)]
512This command deletes all blank characters around the point.
513@enddefcom
514
515@defcom[com "Delete Blank Lines", bind (C-x C-o)]
516This command deletes all blank lines surrounding the current line, leaving the
517point on a single blank line. If the point is already on a single blank line,
518then that line is deleted. If the point is on a non-blank line, then all blank
519lines immediately following that line are deleted. This command is often used
520to clean up after @comref[Open Line].
521@enddefcom
522
523@section[Filtering]
524
525@i[Filtering] is a simple way to perform a fairly arbitrary transformation
526on text. Filtering text replaces the string in each line with the result
527of applying a @llisp function of one argument to that string. The function must
528neither destructively modify the argument nor the return value. It is an
529error for the function to return a string containing newline characters.
530
531@defcom[com "Filter Region"]
532This function prompts for an expression which is evaluated to obtain a
533function to be used to filter the text in the region. For example, to
534capitalize all the words in the region one could respond:
535@begin[programexample]
536Function: #'@comment<>string-capitalize
537@end[programexample]
538Since the function may be called many times, it should probably be
539compiled. Functions for one-time use can be compiled using the compile
540function as in the following example which removes all the semicolons on any line
541which contains the string "@f[PASCAL]":
542@begin[programexample]
543Function: (compile nil '(lambda (s)
544 (if (search "PASCAL" s)
545 (remove #\; s)
546 s)))
547@end[programexample]
548@enddefcom
549
550@section[Searching and Replacing]
551@index[searching]@index[replacing]
552Searching for some string known to appear in the text is a commonly used method
553of moving long distances in a file. Replacing occurrences of one pattern with
554another is a useful way to make many simple changes to text. @hemlock provides
555powerful commands for doing both of these operations.
556
557@defhvar[var "String Search Ignore Case", val {t}]
558@index[case sensitivity]
559This variable determines the kind of search done by searching and replacing
560commands.
561@enddefhvar
562
563@defcom[com "Incremental Search", bind {C-s}]
564@defcom1[com "Reverse Incremental Search", bind {C-r}]
565@hid[Incremental Search] searches for an occurrence of a string after the
566current point. It is known as an incremental search because it reads
567key-events form the keyboard one at a time and immediately searches for the
568pattern of corresponding characters as you type. This is useful because
569it is possible to initially type in a very short pattern and then add more
570characters if it turns out that this pattern has too many spurious matches.
571
572This command dispatches on the following key-events as sub-commands:
573@begin[description]
574@binding[C-s]@\
575 Search forward for an occurrence of the current pattern. This can be used
576repeatedly to skip from one occurrence of the pattern to the next, or it can be
577used to change the direction of the search if it is currently a reverse search.
578If @binding[C-s] is typed when the search string is empty, then a search is
579done for the string that was used by the last searching command.
580
581@binding[C-r]@\
582 Similar to @binding[C-s], except that it searches backwards.
583
584@binding[Delete, Backspace]@\
585 Undoes the effect of the last key-event typed. If that key-event simply added
586to the search pattern, then this removes the character from the pattern, moving
587back to the last match found before entering the removed character. If the
588character was a @binding[C-s] or @binding[C-r], then this moves back to the
589previous match and possibly reverses the search direction.
590
591@binding[C-g]@\
592 If the search is currently failing, meaning that there is no occurrence of the
593search pattern in the direction of search, then @binding[C-g] deletes enough
594characters off the end of the pattern to make it successful. If the search
595is currently successful, then @binding[C-g] causes the search to be aborted,
596leaving the point where it was when the search started. Aborting the search
597inhibits the saving of the current search pattern as the last search string.
598
599@binding[Escape]@\
600 Exit at the current position in the text, unless the search string is empty,
601in which case a non-incremental string search is entered.
602
603@binding[C-q]@\
604 Search for the character corresponding to the next key-event, rather than
605treating it as a command.
606@end[description]
607Any key-event not corresponding to a graphic character, except those just
608described, causes the search to exit. @hemlock then uses the key-event in it
609normal command interpretation.
610
611For example, typing @binding[C-a] will exit the search @i[and] go to the
612beginning of the current line. When either of these commands successfully
613exits, they push the starting position (before the search) on the mark stack.
614If the current region was active when the search started, this foregoes pushing
615a mark.
616@enddefcom
617
618@defcom[com "Forward Search", bind (M-s)]
619@defcom1[com "Reverse Search", bind (M-r)]
620These commands do a normal dumb string search, prompting for the search
621string in a normal dumb fashion. One reason for using a non-incremental
622search is that it may be faster since it is possible to specify a long
623search string from the very start. Since @hemlock uses the Boyer--Moore
624search algorithm, the speed of the search increases with the size of the
625search string.
626When either of these commands successfully exits, they push the starting
627position (before the search) on the mark stack. This is inhibited when the
628current region is active.
629@enddefcom
630
631@defcom[com "Query Replace", bind (M-%)]
632This command prompts in the echo area for a target string and a replacement
633string. It then searches for an occurrence of the target after the point.
634When it finds a match, it prompts for a key-event indicating what action to
635take. The following are valid responses:
636@begin[description]
637@binding[Space, y]@\
638 Replace this occurrence of the target with the replacement string, and search
639again.
640
641@binding[Delete, Backspace, n]@\
642 Do not replace this occurrence, but continue the search.
643
644@binding[!]@\
645 Replace this and all remaining occurrences without prompting again.
646
647@binding[.]@\
648 Replace this occurrence and exit.
649
650@binding[C-r]@\
651 Go into a recursive edit (see page @pageref[recursive-edits]) at the current
652location. The search will be continued from wherever the point is left when
653the recursive edit is exited. This is useful for handling more complicated
654cases where a simple replacement will not achieve the desired effect.
655
656@binding[Escape]@\
657 Exit without doing any replacement.
658
659@binding[Home, C-_, ?, h]@\
660 Print a list of all the options available.
661@end[description]
662Any other key-event causes the command to exit, returning the key-event to the
663input stream; thus, @hemlock will interpret it normally for a command binding.
664
665When the current region is active, this command uses it instead of the region
666from point to the end of the buffer. This is especially useful when you expect
667to use the @binding[!] option.
668
669If the replacement string is all lowercase, then a heuristic is used that
670attempts to make the case of the replacement the same as that of the
671particular occurrence of the target pattern. If "@f[foo]" is being
672replaced with "@f[bar]" then "@f[Foo]" is replaced with "@f[Bar]" and
673"@f[FOO]" with "@f[BAR]".
674
675This command may be undone with @hid[Undo], but its undoing may not be undone.
676On a successful exit from this command, the starting position (before the
677search) is pushed on the mark stack.
678@enddefcom
679
680@defhvar[var "Case Replace", val {t}]
681@index[case sensitivity]
682If this variable is true then the case preserving heuristic in
683@hid[Query Replace] is enabled, otherwise all replacements are done with
684the replacement string exactly as specified.
685@enddefhvar
686
687@defcom[com "Replace String"]
688This command is the same as @hid[Query Replace] except it operates without ever
689querying the user before making replacements. After prompting for a target and
690replacement string, it replaces all occurrences of the target string following
691the point. If a prefix argument is specified, then only that many occurrences
692are replaced. When the current region is active, this command uses it instead
693of the region from point to the end of the buffer.
694@enddefcom
695
696@defcom[com "List Matching Lines"]
697This command prompts for a search string and displays in a pop-up window all
698the lines containing the string that are after the point. If a prefix argument
699is specified, then this displays that many lines before and after each matching
700line. When the current region is active, this command uses it instead of the
701region from point to the end of the buffer.
702@enddefcom
703
704@defcom[com "Delete Matching Lines"]
705@defcom1[com "Delete Non-Matching Lines"]
706@hid[Delete Matching Lines] prompts for a search string and deletes all lines
707containing the string that are after the point. Similarly, @hid[Delete
708Non-Matching Lines] deletes all lines following the point that do not contain
709the specified string. When the current region is active, these commands uses
710it instead of the region from point to the end of the buffer.
711@enddefcom
712
713
714@section[Page Commands]
715@index[page commands]
716Another unit of text recognized by @hemlock is the page. A @i[page] is a piece
717of text delimited by formfeeds (@f[^L]'s.) The first non-blank line after the
718page marker is the @i[page title]. The page commands are quite useful when
719logically distinct parts of a file are put on separate pages. See also
720@comref[Count Lines Page]. These commands only recognize @f[^L]'s at the
721beginning of a lines, so those quoted in string literals do not get in the way.
722
723@defcom[com "Previous Page", bind (C-x @bf<]>)]
724@defcom1[com "Next Page", bind (C-x [)]
725@hid[Previous Page] moves the point to the previous page delimiter, while
726@hid[Next Page] moves to the next one. Any page delimiters next to the point
727are skipped. The prefix argument is a repeat count.
728@enddefcom
729
730@defcom[com "Mark Page", bind (C-x C-p)]
731This command puts the point at the beginning of the current page and the mark
732at the end. If given a prefix argument, marks the page that many pages from the
733current one.
734@enddefcom
735
736@defcom[com "Goto Page"]
737This command does various things, depending on the prefix argument:
738@begin[description]
739@i[no argument]@\goes to the next page.
740
741@i[positive argument]@\goes to an absolute page number, moving that many pages
742from the beginning of the file.
743
744@i[zero argument]@\prompts for string and goes to the page with that string in
745its title. Repeated invocations in this manner continue searching from the
746point of the last find, and a first search with a particular pattern pushes a
747buffer mark.
748
749@i[negative argument]@\moves backward by that many pages, if possible.
750@end[description]
751@enddefcom
752
753@defcom[com "View Page Directory"]
754@defcom1[com "Insert Page Directory"]
755@hid[View Page Directory] uses a pop-up window to display the number and title
756of each page in the current buffer. @hid[Insert Page Directory] is the same
757except that it inserts the text at the beginning of the buffer. With a prefix
758argument, @hid[Insert Page Directory] inserts at the point.
759@enddefcom
760
761
762@section[Counting Commands]
763
764@defcom[com "Count Words"]
765This command counts the number of words from the current point to the end of
766the buffer, displaying a message in the echo area. When the current region is
767active, this uses it instead of the region from the point to the end of the
768buffer. Word delimiters are determined by the current major mode.
769@enddefcom
770
771@defcom[com "Count Lines"]
772This command counts the number of lines from the current point to the end of
773the buffer, displaying a message in the echo area. When the current region is
774active, this uses it instead of the region from the point to the end of the
775buffer.
776@enddefcom
777
778@defcom[com "Count Lines Page", bind (C-x l)]
779This command displays the number of lines in the current page and the number of
780lines before and after the point within that page. If given a prefix argument,
781the entire buffer is counted instead of just the current page.
782@enddefcom
783
784@defcom[com "Count Occurrences"]
785This command prompts for a search string and displays the number of occurrences
786of that string in the text from the point to the end of the buffer. When the
787current region is active, this uses it instead of the region from the point to
788the end of the buffer.
789@enddefcom
790
791
792@section[Registers]
793@index[registers]
794Registers allow you to save a text position or chunk of text associated with a
795key-event. This is a convenient way to repeatedly access a commonly-used
796location or text fragment. The concept and key bindings should be familiar to
797TECO users.
798
799@defcom[com "Save Position", bind (C-x s)]
800@defcom1[com "Jump to Saved Position", bind (C-x j)]
801These commands manipulate registers containing textual positions.
802@hid[Save Position] prompts for a register and saves the location of the
803current point in that register. @hid[Jump to Saved Position] prompts for a
804register and moves the point to the position saved in that register. If the
805saved position is in a different buffer, then that buffer is made current.
806@enddefcom
807
808@defcom[com "Put Register", bind (C-x x)]
809@defcom1[com "Get Register", bind (C-x g)]
810These commands manipulate registers containing text. @hid[Put Register]
811prompts for a register and puts the text in the current region into the
812register. @hid[Get Register] prompts for a register and inserts the text in
813that register at the current point.
814@enddefcom
815
816@defcom[com "List Registers"]
817@defcom1[com "Kill Register"]
818@hid[List Registers] displays a list of all the currently defined registers in
819a pop-up window, along with a brief description of their contents.
820@hid[Kill Register] prompts for the name of a register and deletes that
821register.
822@enddefcom
Note: See TracBrowser for help on using the repository browser.