Mercurial > hg > xemacs-beta
comparison man/xemacs/misc.texi @ 428:3ecd8885ac67 r21-2-22
Import from CVS: tag r21-2-22
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:28:15 +0200 |
parents | |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
427:0a0253eac470 | 428:3ecd8885ac67 |
---|---|
1 | |
2 @iftex | |
3 @chapter Miscellaneous Commands | |
4 | |
5 This chapter contains several brief topics that do not fit anywhere else. | |
6 | |
7 @end iftex | |
8 | |
9 @node Sorting, Shell, Calendar/Diary, Top | |
10 @section Sorting Text | |
11 @cindex sorting | |
12 | |
13 XEmacs provides several commands for sorting text in a buffer. All | |
14 operate on the contents of the region (the text between point and the | |
15 mark). They divide the text of the region into many @dfn{sort records}, | |
16 identify a @dfn{sort key} for each record, and then reorder the records | |
17 using the order determined by the sort keys. The records are ordered so | |
18 that their keys are in alphabetical order, or, for numerical sorting, in | |
19 numerical order. In alphabetical sorting, all upper-case letters `A' | |
20 through `Z' come before lower-case `a', in accordance with the ASCII | |
21 character sequence. | |
22 | |
23 The sort commands differ in how they divide the text into sort | |
24 records and in which part of each record they use as the sort key. Most of | |
25 the commands make each line a separate sort record, but some commands use | |
26 paragraphs or pages as sort records. Most of the sort commands use each | |
27 entire sort record as its own sort key, but some use only a portion of the | |
28 record as the sort key. | |
29 | |
30 @findex sort-lines | |
31 @findex sort-paragraphs | |
32 @findex sort-pages | |
33 @findex sort-fields | |
34 @findex sort-numeric-fields | |
35 @table @kbd | |
36 @item M-x sort-lines | |
37 Divide the region into lines and sort by comparing the entire | |
38 text of a line. A prefix argument means sort in descending order. | |
39 | |
40 @item M-x sort-paragraphs | |
41 Divide the region into paragraphs and sort by comparing the entire | |
42 text of a paragraph (except for leading blank lines). A prefix | |
43 argument means sort in descending order. | |
44 | |
45 @item M-x sort-pages | |
46 Divide the region into pages and sort by comparing the entire | |
47 text of a page (except for leading blank lines). A prefix | |
48 argument means sort in descending order. | |
49 | |
50 @item M-x sort-fields | |
51 Divide the region into lines and sort by comparing the contents of | |
52 one field in each line. Fields are defined as separated by | |
53 whitespace, so the first run of consecutive non-whitespace characters | |
54 in a line constitutes field 1, the second such run constitutes field | |
55 2, etc. | |
56 | |
57 You specify which field to sort by with a numeric argument: 1 to sort | |
58 by field 1, etc. A negative argument means sort in descending | |
59 order. Thus, minus 2 means sort by field 2 in reverse-alphabetical | |
60 order. | |
61 | |
62 @item M-x sort-numeric-fields | |
63 Like @kbd{M-x sort-fields}, except the specified field is converted | |
64 to a number for each line and the numbers are compared. @samp{10} | |
65 comes before @samp{2} when considered as text, but after it when | |
66 considered as a number. | |
67 | |
68 @item M-x sort-columns | |
69 Like @kbd{M-x sort-fields}, except that the text within each line | |
70 used for comparison comes from a fixed range of columns. An explanation | |
71 is given below. | |
72 @end table | |
73 | |
74 For example, if the buffer contains: | |
75 | |
76 @smallexample | |
77 On systems where clash detection (locking of files being edited) is | |
78 implemented, XEmacs also checks the first time you modify a buffer | |
79 whether the file has changed on disk since it was last visited or | |
80 saved. If it has, you are asked to confirm that you want to change | |
81 the buffer. | |
82 @end smallexample | |
83 | |
84 @noindent | |
85 then if you apply @kbd{M-x sort-lines} to the entire buffer you get: | |
86 | |
87 @smallexample | |
88 On systems where clash detection (locking of files being edited) is | |
89 implemented, XEmacs also checks the first time you modify a buffer | |
90 saved. If it has, you are asked to confirm that you want to change | |
91 the buffer. | |
92 whether the file has changed on disk since it was last visited or | |
93 @end smallexample | |
94 | |
95 @noindent | |
96 where the upper case `O' comes before all lower case letters. If you apply | |
97 instead @kbd{C-u 2 M-x sort-fields} you get: | |
98 | |
99 @smallexample | |
100 saved. If it has, you are asked to confirm that you want to change | |
101 implemented, XEmacs also checks the first time you modify a buffer | |
102 the buffer. | |
103 On systems where clash detection (locking of files being edited) is | |
104 whether the file has changed on disk since it was last visited or | |
105 @end smallexample | |
106 | |
107 @noindent | |
108 where the sort keys were @samp{If}, @samp{XEmacs}, @samp{buffer}, | |
109 @samp{systems}, and @samp{the}.@refill | |
110 | |
111 @findex sort-columns | |
112 @kbd{M-x sort-columns} requires more explanation. You specify the | |
113 columns by putting point at one of the columns and the mark at the other | |
114 column. Because this means you cannot put point or the mark at the | |
115 beginning of the first line to sort, this command uses an unusual | |
116 definition of `region': all of the line point is in is considered part of | |
117 the region, and so is all of the line the mark is in. | |
118 | |
119 For example, to sort a table by information found in columns 10 to 15, | |
120 you could put the mark on column 10 in the first line of the table, and | |
121 point on column 15 in the last line of the table, and then use this command. | |
122 Or you could put the mark on column 15 in the first line and point on | |
123 column 10 in the last line. | |
124 | |
125 This can be thought of as sorting the rectangle specified by point and | |
126 the mark, except that the text on each line to the left or right of the | |
127 rectangle moves along with the text inside the rectangle. | |
128 @xref{Rectangles}. | |
129 | |
130 @node Shell, Narrowing, Sorting, Top | |
131 @section Running Shell Commands from XEmacs | |
132 @cindex subshell | |
133 @cindex shell commands | |
134 | |
135 XEmacs has commands for passing single command lines to inferior shell | |
136 processes; it can also run a shell interactively with input and output to | |
137 an XEmacs buffer @samp{*shell*}. | |
138 | |
139 @table @kbd | |
140 @item M-! | |
141 Run a specified shell command line and display the output | |
142 (@code{shell-command}). | |
143 @item M-| | |
144 Run a specified shell command line with region contents as input; | |
145 optionally replace the region with the output | |
146 (@code{shell-command-on-region}). | |
147 @item M-x shell | |
148 Run a subshell with input and output through an XEmacs buffer. | |
149 You can then give commands interactively. | |
150 @item M-x term | |
151 Run a subshell with input and output through an XEmacs buffer. | |
152 You can then give commands interactively. | |
153 Full terminal emulation is available. | |
154 @end table | |
155 | |
156 @menu | |
157 * Single Shell:: How to run one shell command and return. | |
158 * Interactive Shell:: Permanent shell taking input via XEmacs. | |
159 * Shell Mode:: Special XEmacs commands used with permanent shell. | |
160 * Terminal emulator:: An XEmacs window as a terminal emulator. | |
161 * Term Mode:: Special XEmacs commands used in Term mode. | |
162 * Paging in Term:: Paging in the terminal emulator. | |
163 @end menu | |
164 | |
165 @node Single Shell, Interactive Shell, Shell, Shell | |
166 @subsection Single Shell Commands | |
167 | |
168 @kindex M-! | |
169 @findex shell-command | |
170 @kbd{M-!} (@code{shell-command}) reads a line of text using the | |
171 minibuffer and creates an inferior shell to execute the line as a command. | |
172 Standard input from the command comes from the null device. If the shell | |
173 command produces any output, the output goes to an XEmacs buffer named | |
174 @samp{*Shell Command Output*}, which is displayed in another window but not | |
175 selected. A numeric argument, as in @kbd{M-1 M-!}, directs this command to | |
176 insert any output into the current buffer. In that case, point is left | |
177 before the output and the mark is set after the output. | |
178 | |
179 @kindex M-| | |
180 @findex shell-command-on-region | |
181 @kbd{M-|} (@code{shell-command-on-region}) is like @kbd{M-!} but passes | |
182 the contents of the region as input to the shell command, instead of no | |
183 input. If a numeric argument is used to direct output to the current | |
184 buffer, then the old region is deleted first and the output replaces it as | |
185 the contents of the region.@refill | |
186 | |
187 @vindex shell-file-name | |
188 @cindex environment | |
189 Both @kbd{M-!} and @kbd{M-|} use @code{shell-file-name} to specify the | |
190 shell to use. This variable is initialized based on your @code{SHELL} | |
191 environment variable when you start XEmacs. If the file name does not | |
192 specify a directory, the directories in the list @code{exec-path} are | |
193 searched; this list is initialized based on the @code{PATH} environment | |
194 variable when you start XEmacs. You can override either or both of these | |
195 default initializations in your @file{.emacs} file.@refill | |
196 | |
197 When you use @kbd{M-!} and @kbd{M-|}, XEmacs has to wait until the | |
198 shell command completes. You can quit with @kbd{C-g}; that terminates | |
199 the shell command. | |
200 | |
201 @node Interactive Shell, Shell Mode, Single Shell, Shell | |
202 @subsection Interactive Inferior Shell | |
203 | |
204 @findex shell | |
205 To run a subshell interactively with its typescript in an XEmacs | |
206 buffer, use @kbd{M-x shell}. This creates (or reuses) a buffer named | |
207 @samp{*shell*} and runs a subshell with input coming from and output going | |
208 to that buffer. That is to say, any ``terminal output'' from the subshell | |
209 will go into the buffer, advancing point, and any ``terminal input'' for | |
210 the subshell comes from text in the buffer. To give input to the subshell, | |
211 go to the end of the buffer and type the input, terminated by @key{RET}. | |
212 | |
213 XEmacs does not wait for the subshell to do anything. You can switch | |
214 windows or buffers and edit them while the shell is waiting, or while it is | |
215 running a command. Output from the subshell waits until XEmacs has time to | |
216 process it; this happens whenever XEmacs is waiting for keyboard input or | |
217 for time to elapse. | |
218 | |
219 To get multiple subshells, change the name of buffer | |
220 @samp{*shell*} to something different by using @kbd{M-x rename-buffer}. The | |
221 next use of @kbd{M-x shell} creates a new buffer @samp{*shell*} with | |
222 its own subshell. By renaming this buffer as well you can create a third | |
223 one, and so on. All the subshells run independently and in parallel. | |
224 | |
225 @vindex explicit-shell-file-name | |
226 The file name used to load the subshell is the value of the variable | |
227 @code{explicit-shell-file-name}, if that is non-@code{nil}. Otherwise, the | |
228 environment variable @code{ESHELL} is used, or the environment variable | |
229 @code{SHELL} if there is no @code{ESHELL}. If the file name specified | |
230 is relative, the directories in the list @code{exec-path} are searched | |
231 (@pxref{Single Shell,Single Shell Commands}).@refill | |
232 | |
233 As soon as the subshell is started, it is sent as input the contents of | |
234 the file @file{~/.emacs_@var{shellname}}, if that file exists, where | |
235 @var{shellname} is the name of the file that the shell was loaded from. | |
236 For example, if you use @code{csh}, the file sent to it is | |
237 @file{~/.emacs_csh}.@refill | |
238 | |
239 @vindex shell-pushd-regexp | |
240 @vindex shell-popd-regexp | |
241 @vindex shell-cd-regexp | |
242 @code{cd}, @code{pushd}, and @code{popd} commands given to the inferior | |
243 shell are watched by XEmacs so it can keep the @samp{*shell*} buffer's | |
244 default directory the same as the shell's working directory. These | |
245 commands are recognized syntactically by examining lines of input that are | |
246 sent. If you use aliases for these commands, you can tell XEmacs to | |
247 recognize them also. For example, if the value of the variable | |
248 @code{shell-pushd-regexp} matches the beginning of a shell command line, | |
249 that line is regarded as a @code{pushd} command. Change this variable when | |
250 you add aliases for @samp{pushd}. Likewise, @code{shell-popd-regexp} and | |
251 @code{shell-cd-regexp} are used to recognize commands with the meaning of | |
252 @samp{popd} and @samp{cd}.@refill | |
253 | |
254 @kbd{M-x shell-resync-dirs} queries the shell and resynchronizes XEmacs' | |
255 idea of what the current directory stack is. @kbd{M-x | |
256 shell-dirtrack-toggle} turns directory tracking on and off. | |
257 | |
258 @vindex input-ring-size | |
259 XEmacs keeps a history of the most recent commands you have typed in the | |
260 @samp{*shell*} buffer. If you are at the beginning of a shell command | |
261 line and type @key{M-p}, the previous shell input is inserted into the | |
262 buffer before point. Immediately typing @key{M-p} again deletes that | |
263 input and inserts the one before it. By repeating @key{M-p} you can | |
264 move backward through your commands until you find one you want to | |
265 repeat. You may then edit the command before typing @key{RET} if you | |
266 wish. @key{M-n} moves forward through the command history, in case you | |
267 moved backward past the one you wanted while using @key{M-p}. If you | |
268 type the first few characters of a previous command and then type | |
269 @key{M-p}, the most recent shell input starting with those characters is | |
270 inserted. This can be very convenient when you are repeating a sequence | |
271 of shell commands. The variable @code{input-ring-size} controls how | |
272 many commands are saved in your input history. The default is 30. | |
273 | |
274 | |
275 @node Shell Mode, Terminal emulator, Interactive Shell, Shell | |
276 @subsection Shell Mode | |
277 | |
278 @cindex Shell mode | |
279 The shell buffer uses Shell mode, which defines several special keys | |
280 attached to the @kbd{C-c} prefix. They are chosen to resemble the usual | |
281 editing and job control characters present in shells that are not under | |
282 XEmacs, except that you must type @kbd{C-c} first. Here is a list | |
283 of the special key bindings of Shell mode: | |
284 | |
285 @kindex RET (Shell mode) | |
286 @kindex C-c C-d (Shell mode) | |
287 @kindex C-d (Shell mode) | |
288 @kindex C-c C-u (Shell mode) | |
289 @kindex C-c C-w (Shell mode) | |
290 @kindex C-c C-c (Shell mode) | |
291 @kindex C-c C-z (Shell mode) | |
292 @kindex C-c C-\ (Shell mode) | |
293 @kindex C-c C-o (Shell mode) | |
294 @kindex C-c C-r (Shell mode) | |
295 @kindex C-c C-y (Shell mode) | |
296 @kindex M-p (Shell mode) | |
297 @kindex M-n (Shell mode) | |
298 @kindex TAB (Shell mode) | |
299 @findex send-shell-input | |
300 @findex shell-send-eof | |
301 @findex comint-delchar-or-maybe-eof | |
302 @findex interrupt-shell-subjob | |
303 @findex stop-shell-subjob | |
304 @findex quit-shell-subjob | |
305 @findex kill-output-from-shell | |
306 @findex show-output-from-shell | |
307 @findex copy-last-shell-input | |
308 @findex comint-previous-input | |
309 @findex comint-next-input | |
310 @findex comint-dynamic-complete | |
311 @vindex shell-prompt-pattern | |
312 @table @kbd | |
313 @item @key{RET} | |
314 At end of buffer send line as input; otherwise, copy current line to end of | |
315 buffer and send it (@code{send-shell-input}). When a line is copied, any | |
316 text at the beginning of the line that matches the variable | |
317 @code{shell-prompt-pattern} is left out; this variable's value should be a | |
318 regexp string that matches the prompts that you use in your subshell. | |
319 @item C-c C-d | |
320 Send end-of-file as input, probably causing the shell or its current | |
321 subjob to finish (@code{shell-send-eof}). | |
322 @item C-d | |
323 If point is not at the end of the buffer, delete the next character just | |
324 like most other modes. If point is at the end of the buffer, send | |
325 end-of-file as input, instead of generating an error as in other modes | |
326 (@code{comint-delchar-or-maybe-eof}). | |
327 @item C-c C-u | |
328 Kill all text that has yet to be sent as input (@code{kill-shell-input}). | |
329 @item C-c C-w | |
330 Kill a word before point (@code{backward-kill-word}). | |
331 @item C-c C-c | |
332 Interrupt the shell or its current subjob if any | |
333 (@code{interrupt-shell-subjob}). | |
334 @item C-c C-z | |
335 Stop the shell or its current subjob if any (@code{stop-shell-subjob}). | |
336 @item C-c C-\ | |
337 Send quit signal to the shell or its current subjob if any | |
338 (@code{quit-shell-subjob}). | |
339 @item C-c C-o | |
340 Delete last batch of output from shell (@code{kill-output-from-shell}). | |
341 @item C-c C-r | |
342 Scroll top of last batch of output to top of window | |
343 (@code{show-output-from-shell}). | |
344 @item C-c C-y | |
345 Copy the previous bunch of shell input and insert it into the | |
346 buffer before point (@code{copy-last-shell-input}). No final newline | |
347 is inserted, and the input copied is not resubmitted until you type | |
348 @key{RET}. | |
349 @item M-p | |
350 Move backward through the input history. Search for a matching command | |
351 if you have typed the beginning of a command (@code{comint-previous-input}). | |
352 @item M-n | |
353 Move forward through the input history. Useful when you are | |
354 using @key{M-p} quickly and go past the desired command | |
355 (@code{comint-next-input}). | |
356 @item @key{TAB} | |
357 Complete the file name preceding point (@code{comint-dynamic-complete}). | |
358 @end table | |
359 | |
360 @node Terminal emulator, Term Mode, Shell Mode, Shell | |
361 @subsection Interactive Inferior Shell with Terminal Emulator | |
362 @findex term | |
363 | |
364 To run a subshell in a terminal emulator, putting its typescript in an XEmacs | |
365 buffer, use @kbd{M-x term}. This creates (or reuses) a buffer named | |
366 @samp{*term*} and runs a subshell with input coming from your keyboard and | |
367 output going to that buffer. | |
368 | |
369 All the normal keys that you type are sent without any interpretation | |
370 by XEmacs directly to the subshell, as ``terminal input.'' | |
371 Any ``echo'' of your input is the responsibility of the subshell. | |
372 (The exception is the terminal escape character, | |
373 which by default is @kbd{C-c}. @pxref{Term Mode}.) | |
374 Any ``terminal output'' from the subshell goes into the buffer, | |
375 advancing point. | |
376 | |
377 Some programs (such as XEmacs itself) need to control the | |
378 appearance on the terminal screen in detail. They do this by | |
379 sending special control codes. The exact control | |
380 codes needed vary from terminal to terminal, but nowadays | |
381 most terminals and terminal emulators (including xterm) | |
382 understand the so-called "ANSI escape sequences" (first | |
383 popularized by the Digital's VT100 family of terminal). | |
384 The term mode also understands these escape sequences, | |
385 and for each control code does the appropriate thing | |
386 to change the buffer so that the appearance of the window | |
387 will match what it would be on a real terminal. | |
388 Thus you can actually run XEmacs inside an XEmacs Term window! | |
389 | |
390 XEmacs does not wait for the subshell to do anything. You can switch | |
391 windows or buffers and edit them while the shell is waiting, or while | |
392 it is running a command. Output from the subshell waits until XEmacs | |
393 has time to process it; this happens whenever XEmacs is waiting for | |
394 keyboard input or for time to elapse. | |
395 | |
396 To make multiple terminal emulators, rename the buffer @samp{*term*} | |
397 to something different using @kbd{M-x rename-uniquely}, | |
398 just as with Shell mode. | |
399 | |
400 The file name used to load the subshell is determined | |
401 the same way as for Shell mode. | |
402 | |
403 Unlike Shell mode, Term mode does not track the current directory | |
404 by examining your input. Instead, if you use a programmable | |
405 shell, you can have it tell Term what the current directory is. | |
406 This is done automatically by bash for version 1.15 and later. | |
407 | |
408 @node Term Mode, Paging in Term, Terminal emulator, Shell | |
409 @subsection Term Mode | |
410 @cindex Term mode | |
411 @cindex mode, Term | |
412 | |
413 Term uses Term mode, which has two input modes: | |
414 In line mode, Term basically acts like Shell mode. @xref{Shell Mode}. | |
415 In Char mode, each character is sent directly to the inferior subshell, | |
416 except for the Term escape character, normally @kbd{C-c}. | |
417 | |
418 To switch between line and char mode, use these commands: | |
419 @table @kbd | |
420 @kindex C-c C-k @r{(Term mode)} | |
421 findex term-char-mode | |
422 @item C-c C-k | |
423 Switch to line mode. Do nothing if already in line mode. | |
424 | |
425 @kindex C-c C-j @r{(Term mode)} | |
426 @findex term-line-mode | |
427 @item C-c C-j | |
428 Switch to char mode. Do nothing if already in char mode. | |
429 @end table | |
430 | |
431 The following commands are only available in Char mode: | |
432 @table @kbd | |
433 @item C-c C-c | |
434 Send a literal @key{C-c} to the sub-shell. | |
435 | |
436 @item C-c C-x | |
437 A prefix command to conveniently access the global @key{C-x} commands. | |
438 For example, @kbd{C-c C-x o} invokes the global binding of | |
439 @kbd{C-x o}, which is normally @samp{other-window}. | |
440 @end table | |
441 | |
442 @node Paging in Term,, Term Mode, Shell | |
443 @subsection Paging in the terminal emulator | |
444 | |
445 Term mode has a pager feature. When the pager is enabled, | |
446 term mode will pause at the end of each screenful. | |
447 | |
448 @table @kbd | |
449 @kindex C-c C-q @r{(Term mode)} | |
450 @findex term-pager-toggle | |
451 @item C-c C-q | |
452 Toggles the pager feature: Disables the pager if it is enabled, | |
453 and vice versa. This works in both line and char modes. | |
454 If the pager enabled, the mode-line contains the word @samp{page}. | |
455 @end table | |
456 | |
457 If the pager is enabled, and Term receives more than a screenful | |
458 of output since your last input, Term will enter More break mode. | |
459 This is indicated by @samp{**MORE**} in the mode-line. | |
460 Type a @kbd{Space} to display the next screenful of output. | |
461 Type @kbd{?} to see your other options. The interface is similar | |
462 to the Unix @samp{more} program. | |
463 | |
464 @node Narrowing, Hardcopy, Shell, Top | |
465 @section Narrowing | |
466 @cindex widening | |
467 @cindex restriction | |
468 @cindex narrowing | |
469 | |
470 @dfn{Narrowing} means focusing in on some portion of the buffer, making | |
471 the rest temporarily invisible and inaccessible. Cancelling the narrowing | |
472 and making the entire buffer once again visible is called @dfn{widening}. | |
473 The amount of narrowing in effect in a buffer at any time is called the | |
474 buffer's @dfn{restriction}. | |
475 | |
476 @c WideCommands | |
477 @table @kbd | |
478 @item C-x n n | |
479 Narrow down to between point and mark (@code{narrow-to-region}). | |
480 @item C-x n w | |
481 Widen to make the entire buffer visible again (@code{widen}). | |
482 @end table | |
483 | |
484 Narrowing sometimes makes it easier to concentrate on a single | |
485 subroutine or paragraph by eliminating clutter. It can also be used to | |
486 restrict the range of operation of a replace command or repeating | |
487 keyboard macro. The word @samp{Narrow} appears in the mode line | |
488 whenever narrowing is in effect. When you have narrowed to a part of the | |
489 buffer, that part appears to be all there is. You can't see the rest, | |
490 can't move into it (motion commands won't go outside the visible part), | |
491 and can't change it in any way. However, the invisible text is not | |
492 gone; if you save the file, it will be saved. | |
493 | |
494 @kindex C-x n n | |
495 @findex narrow-to-region | |
496 The primary narrowing command is @kbd{C-x n n} (@code{narrow-to-region}). | |
497 It sets the current buffer's restrictions so that the text in the current | |
498 region remains visible but all text before the region or after the region | |
499 is invisible. Point and mark do not change. | |
500 | |
501 Because narrowing can easily confuse users who do not understand it, | |
502 @code{narrow-to-region} is normally a disabled command. Attempting to use | |
503 this command asks for confirmation and gives you the option of enabling it; | |
504 once you enable the command, confirmation will no longer be required. @xref{Disabling}. | |
505 | |
506 @kindex C-x n w | |
507 @findex widen | |
508 To undo narrowing, use @kbd{C-x n w} (@code{widen}). This makes all | |
509 text in the buffer accessible again. | |
510 | |
511 Use the @kbd{C-x =} command to get information on what part of the | |
512 buffer you narrowed down. @xref{Position Info}. | |
513 | |
514 @node Hardcopy, Recursive Edit, Narrowing, Top | |
515 @section Hardcopy Output | |
516 @cindex hardcopy | |
517 | |
518 The XEmacs commands for making hardcopy derive their names from the | |
519 Unix commands @samp{print} and @samp{lpr}. | |
520 | |
521 @table @kbd | |
522 @item M-x print-buffer | |
523 Print hardcopy of current buffer using Unix command @samp{print} | |
524 @*(@samp{lpr -p}). This command adds page headings containing the file name | |
525 and page number. | |
526 @item M-x lpr-buffer | |
527 Print hardcopy of current buffer using Unix command @samp{lpr}. | |
528 This command does not add page headings. | |
529 @item M-x print-region | |
530 Like @code{print-buffer}, but prints only the current region. | |
531 @item M-x lpr-region | |
532 Like @code{lpr-buffer}, but prints only the current region. | |
533 @end table | |
534 | |
535 @findex print-buffer | |
536 @findex print-region | |
537 @findex lpr-buffer | |
538 @findex lpr-region | |
539 @vindex lpr-switches | |
540 All the hardcopy commands pass extra switches to the @code{lpr} program | |
541 based on the value of the variable @code{lpr-switches}. Its value should | |
542 be a list of strings, each string a switch starting with @samp{-}. For | |
543 example, the value could be @code{("-Pfoo")} to print on printer | |
544 @samp{foo}. | |
545 | |
546 @node Recursive Edit, Dissociated Press, Hardcopy, Top | |
547 @section Recursive Editing Levels | |
548 @cindex recursive editing level | |
549 @cindex editing level, recursive | |
550 | |
551 A @dfn{recursive edit} is a situation in which you are using XEmacs | |
552 commands to perform arbitrary editing while in the middle of another | |
553 XEmacs command. For example, when you type @kbd{C-r} inside a | |
554 @code{query-replace}, you enter a recursive edit in which you can change | |
555 the current buffer. When you exit from the recursive edit, you go back to | |
556 the @code{query-replace}. | |
557 | |
558 @kindex C-M-c | |
559 @findex exit-recursive-edit | |
560 @cindex exiting | |
561 @dfn{Exiting} a recursive edit means returning to the unfinished | |
562 command, which continues execution. For example, exiting the recursive | |
563 edit requested by @kbd{C-r} in @code{query-replace} causes query replacing | |
564 to resume. Exiting is done with @kbd{C-M-c} (@code{exit-recursive-edit}). | |
565 | |
566 @kindex C-] | |
567 @findex abort-recursive-edit | |
568 You can also @dfn{abort} a recursive edit. This is like exiting, but | |
569 also quits the unfinished command immediately. Use the command @kbd{C-]} | |
570 (@code{abort-recursive-edit}) for this. @xref{Quitting}. | |
571 | |
572 The mode line shows you when you are in a recursive edit by displaying | |
573 square brackets around the parentheses that always surround the major | |
574 and minor mode names. Every window's mode line shows the square | |
575 brackets, since XEmacs as a whole, rather than any particular buffer, is | |
576 in a recursive edit. | |
577 | |
578 @findex top-level | |
579 It is possible to be in recursive edits within recursive edits. For | |
580 example, after typing @kbd{C-r} in a @code{query-replace}, you might | |
581 type a command that entered the debugger. In such a case, two or | |
582 more sets of square brackets appear in the mode line(s). Exiting the | |
583 inner recursive edit (here with the debugger @kbd{c} command) | |
584 resumes the query-replace command where it called the debugger. After | |
585 the end of the query-replace command, you would be able to exit the | |
586 first recursive edit. Aborting exits only one level of recursive edit; | |
587 it returns to the command level of the previous recursive edit. You can | |
588 then abort that one as well. | |
589 | |
590 The command @kbd{M-x top-level} aborts all levels of | |
591 recursive edits, returning immediately to the top level command reader. | |
592 | |
593 The text you edit inside the recursive edit need not be the same text | |
594 that you were editing at top level. If the command that invokes the | |
595 recursive edit selects a different buffer first, that is the buffer you | |
596 will edit recursively. You can switch buffers within the recursive edit | |
597 in the normal manner (as long as the buffer-switching keys have not been | |
598 rebound). While you could theoretically do the rest of your editing | |
599 inside the recursive edit, including visiting files, this could have | |
600 surprising effects (such as stack overflow) from time to time. It is | |
601 best if you always exit or abort a recursive edit when you no longer | |
602 need it. | |
603 | |
604 In general, XEmacs tries to avoid using recursive edits. It is | |
605 usually preferable to allow users to switch among the possible editing | |
606 modes in any order they like. With recursive edits, the only way to get | |
607 to another state is to go ``back'' to the state that the recursive edit | |
608 was invoked from. | |
609 | |
610 @node Dissociated Press, CONX, Recursive Edit, Top | |
611 @section Dissociated Press | |
612 | |
613 @findex dissociated-press | |
614 @kbd{M-x dissociated-press} is a command for scrambling a file of text | |
615 either word by word or character by character. Starting from a buffer of | |
616 straight English, it produces extremely amusing output. The input comes | |
617 from the current XEmacs buffer. Dissociated Press writes its output in a | |
618 buffer named @samp{*Dissociation*}, and redisplays that buffer after every | |
619 couple of lines (approximately) to facilitate reading it. | |
620 | |
621 @code{dissociated-press} asks every so often whether to continue | |
622 operating. Answer @kbd{n} to stop it. You can also stop at any time by | |
623 typing @kbd{C-g}. The dissociation output remains in the @samp{*Dissociation*} | |
624 buffer for you to copy elsewhere if you wish. | |
625 | |
626 @cindex presidentagon | |
627 Dissociated Press operates by jumping at random from one point in the | |
628 buffer to another. In order to produce plausible output rather than | |
629 gibberish, it insists on a certain amount of overlap between the end of one | |
630 run of consecutive words or characters and the start of the next. That is, | |
631 if it has just printed out `president' and then decides to jump to a | |
632 different point in the file, it might spot the `ent' in `pentagon' and | |
633 continue from there, producing `presidentagon'. Long sample texts produce | |
634 the best results. | |
635 | |
636 @cindex againformation | |
637 A positive argument to @kbd{M-x dissociated-press} tells it to operate | |
638 character by character, and specifies the number of overlap characters. A | |
639 negative argument tells it to operate word by word and specifies the number | |
640 of overlap words. In this mode, whole words are treated as the elements to | |
641 be permuted, rather than characters. No argument is equivalent to an | |
642 argument of two. For your againformation, the output goes only into the | |
643 buffer @samp{*Dissociation*}. The buffer you start with is not changed. | |
644 | |
645 @cindex Markov chain | |
646 @cindex ignoriginal | |
647 @cindex techniquitous | |
648 Dissociated Press produces nearly the same results as a Markov chain | |
649 based on a frequency table constructed from the sample text. It is, | |
650 however, an independent, ignoriginal invention. Dissociated Press | |
651 techniquitously copies several consecutive characters from the sample | |
652 between random choices, whereas a Markov chain would choose randomly for | |
653 each word or character. This makes for more plausible sounding results | |
654 and runs faster. | |
655 | |
656 @cindex outragedy | |
657 @cindex buggestion | |
658 @cindex properbose | |
659 It is a mustatement that too much use of Dissociated Press can be a | |
660 developediment to your real work. Sometimes to the point of outragedy. | |
661 And keep dissociwords out of your documentation, if you want it to be well | |
662 userenced and properbose. Have fun. Your buggestions are welcome. | |
663 | |
664 @node CONX, Amusements, Dissociated Press, Top | |
665 @section CONX | |
666 @cindex random sentences | |
667 | |
668 Besides producing a file of scrambled text with Dissociated Press, you | |
669 can generate random sentences by using CONX. | |
670 | |
671 @table @kbd | |
672 @item M-x conx | |
673 Generate random sentences in the @code{*conx*} buffer. | |
674 @item M-x conx-buffer | |
675 Absorb the text in the current buffer into the @code{conx} database. | |
676 @item M-x conx-init | |
677 Forget the current word-frequency tree. | |
678 @item M-x conx-load | |
679 Load a @code{conx} database that has been previously saved with | |
680 @code{M-x conx-save}. | |
681 @item M-x conx-region | |
682 Absorb the text in the current buffer into the @code{conx} database. | |
683 @item M-x conx-save | |
684 Save the current @code{conx} database to a file for future retrieval. | |
685 @end table | |
686 | |
687 @findex conx | |
688 @findex conx-buffer | |
689 @findex conx-load | |
690 @findex conx-region | |
691 @findex conx-init | |
692 @findex conx-save | |
693 | |
694 Copy text from a buffer using @kbd{M-x conx-buffer} or @kbd{M-x conx-region} | |
695 and then type @kbd{M-x conx}. Output is continuously generated until you | |
696 type @key{^G}. You can save the @code{conx} database to a file with | |
697 @kbd{M-x conx-save}, which you can retrieve with @code{M-x conx-load}. | |
698 To clear the database, use @code{M-x conx-init}. | |
699 | |
700 @node Amusements, Emulation, CONX, Top | |
701 @section Other Amusements | |
702 @cindex boredom | |
703 @findex hanoi | |
704 @findex yow | |
705 | |
706 If you are a little bit bored, you can try @kbd{M-x hanoi}. If you are | |
707 considerably bored, give it a numeric argument. If you are very, very | |
708 bored, try an argument of 9. Sit back and watch. | |
709 | |
710 When you are frustrated, try the famous Eliza program. Just do | |
711 @kbd{M-x doctor}. End each input by typing @kbd{RET} twice. | |
712 | |
713 When you are feeling strange, type @kbd{M-x yow}. | |
714 | |
715 @node Emulation, Customization, Amusements, Top | |
716 @comment node-name, next, previous, up | |
717 @section Emulation | |
718 @cindex other editors | |
719 @cindex vi | |
720 @cindex EDT | |
721 | |
722 XEmacs can be programmed to emulate (more or less) most other | |
723 editors. Standard facilities can emulate these: | |
724 | |
725 @table @asis | |
726 @item Viper (a vi emulator) | |
727 @cindex Viper | |
728 In XEmacs, Viper is the preferred emulation of vi within XEmacs. | |
729 Viper is designed to allow you to take advantage of the best | |
730 features of XEmacs while still doing your basic editing in a | |
731 familiar, vi-like fashion. Viper provides various different | |
732 levels of vi emulation, from a quite complete emulation that | |
733 allows almost no access to native XEmacs commands, to an | |
734 ``expert'' mode that combines the most useful vi commands with | |
735 the most useful XEmacs commands. | |
736 | |
737 To start Viper, put the command | |
738 | |
739 @example | |
740 (viper-mode) | |
741 @end example | |
742 | |
743 in your @file{.emacs} file. | |
744 | |
745 Viper comes with a separate manual that is provided standard | |
746 with the XEmacs distribution. | |
747 | |
748 @ignore | |
749 @item evi (alternative vi emulator) | |
750 @cindex evi | |
751 evi is an alternative vi emulator that also provides a nearly complete | |
752 emulation of vi. | |
753 | |
754 evi comes with a separate manual that is provided standard | |
755 with the XEmacs distribution. | |
756 | |
757 Warning: loading more than one vi emulator at once may cause name | |
758 conflicts; no one has checked. | |
759 @end ignore | |
760 | |
761 @item EDT (DEC VMS editor) | |
762 @findex edt-emulation-on | |
763 @findex edt-emulation-off | |
764 Turn on EDT emulation with @kbd{M-x edt-emulation-on}. @kbd{M-x | |
765 @*edt-emulation-off} restores normal Emacs command bindings. | |
766 | |
767 Most of the EDT emulation commands are keypad keys, and most standard | |
768 Emacs key bindings are still available. The EDT emulation rebindings | |
769 are done in the global keymap, so there is no problem switching | |
770 buffers or major modes while in EDT emulation. | |
771 | |
772 @item Gosling Emacs | |
773 @findex set-gosmacs-bindings | |
774 @findex set-gnu-bindings | |
775 Turn on emulation of Gosling Emacs (aka Unipress Emacs) with @kbd{M-x | |
776 set-gosmacs-bindings}. This redefines many keys, mostly on the | |
777 @kbd{C-x} and @kbd{ESC} prefixes, to work as they do in Gosmacs. | |
778 @kbd{M-x set-gnu-bindings} returns to normal XEmacs by rebinding | |
779 the same keys to the definitions they had at the time @kbd{M-x | |
780 set-gosmacs-bindings} was done. | |
781 | |
782 It is also possible to run Mocklisp code written for Gosling Emacs. | |
783 @xref{Mocklisp}. | |
784 @end table |