Add support for Unix lookup by name to user-uid and user-gid
[sxemacs] / info / term.texi
1 \input texinfo @c -*-texinfo-*-
2 settitle Notes about emacs Term mode
3 @setfilename term.info
4
5 @titlepage
6 @sp 6
7 @center @titlefont{Notes about Emacs TERM Mode}
8 @end titlepage
9
10 @ifinfo
11 @dircategory SXEmacs Editor
12 @direntry
13 * Term mode: (term).            Emacs terminal emulator mode.
14 @end direntry
15 @end ifinfo
16
17 @ifnottex
18 @node Top, , (DIR)
19 @top Terminal emulator mode
20 @end ifnottex
21
22 This is some notes about the term Emacs mode.
23
24 @menu
25 * term mode::
26 @end menu
27
28 @node term mode
29 @chapter Term Mode
30
31 @menu
32 * Overview::
33 * Connecting to remote computers::
34 * Paging::
35 * Terminal escapes::
36 @end menu
37
38 The @code{term} package includes the major modes @code{term},
39 @code{shell}, and @code{gud} (for running gbd or another debugger).
40 It is a replacement for the comint mode of Emacs 19,
41 as well as shell, gdb, terminal, and telnet modes.
42 The package works best with recent releases of Emacs 19,
43 but will also work reasonably well with Emacs 18 as well as Lucid Emacs 19.
44
45 The file @code{nshell.el} is a wrapper to use unless term mode
46 is built into Emacs.  If works around some of the missing
47 in older Emacs versions.
48 To use it, edit the paths in @code{nshell.el}, appropriately,
49 and then @code{M-x load-file nshell.el RET}.
50 This will also load in replacement shell and gud modes.
51
52 @node Overview
53 @section Overview
54
55 The @code{term} mode is used to control a program (an "inferior process").
56 It sends most keyboard input characters to the program,
57 and displays output from the program in the buffer.
58 This is similar to the traditional comint mode, and
59 modes derived from it (such as shell and gdb modes).
60 You can do with the new term-based shell the same sort
61 of things you could do with the old shell mode,
62 using more or less the same interface.  However, the
63 new mode is more flexible, and works somewhat differently.
64
65 @menu
66 * Output from the inferior::
67 * subbuffer:: The sub-buffer
68 * altsubbuffer:: The alternate sub-buffer
69 * Input to the inferior::
70 @end menu
71
72 @node Output from the inferior
73 @subsection Output from the inferior
74
75 In typical usage, output from the inferior is
76 added to the end of the buffer.  If needed, the window
77 will be scrolled, just like a regular terminal.
78 (Only one line at a time will be scrolled, just like
79 regular terminals, and in contrast to the old shell mode.)
80 Thus the buffer becomes a log of your interaction with the
81 inferior, just like the old shell mode.
82
83 Like a real terminal, term maintains a "cursor position."
84 This is the @code{process-mark} of the inferior process.
85 If the process-mark is not at the end of the buffer, output from
86 the inferior will overwrite existing text in the buffer.
87 This is like a real terminal, but unlike the old shell mode
88 (which inserts the output, instead of overwriting).
89
90 Some programs (such as Emacs itself) need to control the
91 appearance on the screen in detail.  They do this by
92 sending special control codes.  The exact control
93 codes needed from terminal to terminal, but nowadays
94 most terminals and terminal emulators (including xterm)
95 understand the so-called "ANSI escape sequences" (first
96 popularized by the Digital's VT100 family of terminal).
97 The term mode also understands these escape sequences,
98 and for each control code does the appropriate thing
99 to change the buffer so that the appearance of the window
100 will match what it would be on a real terminal.
101 (In contrast, the old shell mode doesn't handle
102 terminal control codes at all.)
103
104 See <...> for the specific control codes.
105
106 @node subbuffer
107 @subsection The sub-buffer
108
109 A program that talks to terminal expects the terminal to have a fixed size.
110 If the program is talking a terminal emulator program such as @code{xterm},
111 that size can be changed (if the xterm window is re-sized), but programs
112 still assume a logical terminal that has a fixed size independent
113 of the amount of output transmitted by the programs.
114
115 To programs that use it, the Emacs terminal emulator acts as if it
116 too has a fixed size.  The @dfn{sub-buffer} is the part of a @code{term}-mode
117 buffer that corresponds to a "normal" terminal.  Most of the time
118 (unless you explicitly scroll the window displaying the buffer),
119 the sub-buffer is the part of the buffer that is displayed in a window.
120
121 The sub-buffer is defined in terms of three buffer-local-variable:
122
123 @defvar term-height
124 The height of the sub-buffer, in screen lines.
125 @end defvar
126
127 @defvar term-width
128 The width of the sub-buffer, in screen columns.
129 @end defvar
130
131 @defvar term-home-marker
132 The "home" position, that is the top left corner of the sub-buffer.
133 @end defvar
134
135 The sub-buffer is assumed to be the end part of the buffer;
136 the @code{term-home-marker} should never be more than
137 @code{term-height} screen lines from the end of the buffer.
138
139 @node altsubbuffer
140 @subsection The alternate sub-buffer
141
142 When a "graphical" program finishes, it is nice to
143 restore the screen state to what it was before the program started.
144 Many people are used to this behavior from @code{xterm}, and
145 its also offered by the @code{term} emulator.
146
147 @defun term-switch-to-alternate-sub-buffer set
148 If @var{set} is true, and we're not already using the alternate sub-buffer,
149 switch to it.  What this means is that the @code{term-home-marker}
150 is saved (in the variable @code{term-saved-home-marker}), and the
151 @code{term-home-marker} is set to the end of the buffer.
152
153 If @var{set} is false and we're using the alternate sub-buffer,
154 switch back to the saved sub-buffer.  What this means is that the
155 (current, alternate) sub-buffer is deleted (using
156 @code{(delete-region term-home-marker (point-max))}), and then the
157 @code{term-home-marker} is restored (from @code{term-saved-home-marker}).
158 @end defun
159
160 @node Input to the inferior
161 @subsection Input to the inferior
162
163 Characters typed by the user are sent to the inferior.
164 How this is done depends on whether the @code{term} buffer
165 is in "character" mode or "line" mode.
166 (A @code{term} buffer can also be in "pager" mode.
167 This is discussed <later>.)
168 Which of these is currently active is specified in the mode line.
169 The difference between them is the key-bindings available.
170
171 In character mode, one character (by default @key{C-c}) is special,
172 and is a prefix for various commands.  All other characters are
173 sent directly to the inferior process, with no interpretation by Emacs.
174 Character mode looks and feels like a real terminal, or a conventional
175 terminal emulator such as xterm.
176
177 In line mode, key commands mostly have standard Emacs actions.
178 Regulars characters insert themselves into the buffer.
179 When return is typed, the entire current line of the buffer
180 (except possibly the prompt) is sent to the inferior process.
181 Line mode is basically the original shell mode from earlier Emacs versions.
182
183 To switch from line mode to character mode type @kbd{C-c C-k}.
184 To switch from character mode to line mode type @kbd{C-c C-j}.
185
186 In either mode, "echoing" of user input is handled by the inferior.
187 Therefor, in line mode after an input line at the end of the buffer
188 is sent to the inferior, it is deleted from the buffer.
189 This is so that the inferior can echo the input, if it wishes
190 (which it normally does).
191
192 @node Connecting to remote computers
193 @section Connecting to remote computers
194
195 If you want to login to a remove computer, you can do that just as
196 you would expect, using whatever commands you would normally use.
197
198 (This is worth emphasizing, because earlier versions of @code{shell}
199 mode would not work properly if you tried to log in to some other
200 computer, because of the way echoing was handled.  That is why
201 there was a separate @code{telnet} mode to partially compensate for
202 these problems.  The @code{telnet} mode is no longer needed, and
203 is basically obsolete.)
204
205 A program that asks you for a password will normally suppress
206 echoing of the password, so the password will not show up in the buffer.
207 This will happen just as if you were using a real terminal, if
208 the buffer is in char mode.  If it is in line mode, the password
209 will be temporarily visible, but will be erased when you hit return.
210 (This happens automatically; there is no special password processing.)
211
212 When you log in to a different machine, you need to specify the
213 type of terminal your using.   If you are talking to a Bourne-compatible
214 shell, and your system understands the @code{TERMCAP} variable,
215 you can use the command @kbd{M-x shell-send-termcap}, which
216 sends a string specifying the terminal type and size.
217 (This command is also useful after the window has changed size.)
218
219 If you need to specify the terminal type manually, you can try the
220 terminal types "ansi" or "vt100".
221
222 You can of course run gdb on that remote computer.  One useful
223 trick:  If you invoke gdb with the @code{--fullname} option,
224 it will send special commands to Emacs that will cause Emacs to
225 pop up the source files you're debugging.  This will work
226 whether or not gdb is running on a different computer than Emacs,
227 assuming can access the source files specified by gdb.
228
229 @node Paging
230 @section Paging
231
232 When the pager is enabled, Emacs will "pause" after each screenful
233 of output (since the last input sent to the inferior).
234 It will enter "pager" mode, which feels a lot like the "more"
235 program:  Typing a space requests another screenful of output.
236 Other commands request more or less output, or scroll backwards
237 in the @code{term} buffer.  In pager mode, type @kbd{h} or @kbd{?}
238 to display a help message listing all the available pager mode commands.
239
240 In either character or line mode, type @kbd{C-c p} to enable paging,
241 and @kbd{C-c D} to disable it.
242
243 @node Terminal escapes
244 @section Terminal Escape sequences
245
246 A program that does "graphics" on a terminal controls the
247 terminal by sending strings called @dfn{terminal escape sequences}
248 that the terminal (or terminal emulator) interprets as special commands.
249 The @code{term} mode includes a terminal emulator that understands
250 standard ANSI escape sequences, originally popularized by VT100 terminals,
251 and now used by the @code{xterm} program and most modern terminal
252 emulator software.
253
254 @menu
255 * Cursor motion:: Escape sequences to move the cursor
256 * Erasing:: Escape commands for erasing text
257 * Inserting and deleting:: Escape sequences to insert and delete text
258 * Scrolling:: Escape sequences to scroll part of the visible window
259 * Command hook::
260 * Miscellaneous escapes::
261 @end menu
262
263 printing chars
264
265 tab
266
267 LF
268
269 @node Cursor motion
270 @subsection Escape sequences to move the cursor
271
272 @table @kbd
273 @item RETURN
274 Moves to the beginning of the current screen line.
275
276 @item C-b
277 Moves backwards one column.  (Tabs are broken up if needed.)
278 @comment Line wrap FIXME
279
280 @item Esc [ R ; C H
281 Move to screen row R, screen column C, where (R=1) is the top row,
282 and (C=1) is the leftmost column.  Defaults are R=1 and C=1.
283
284 @item Esc [ N A
285 Move N (default 1) screen lines up.
286 @item Esc [ N B
287 Move N (default 1) screen lines down.
288 @item Esc [ N C
289 Move N (default 1) columns right.
290 @item Esc [ N D
291 Move N (default 1) columns left.
292 @end table
293
294 @node Erasing
295 @subsection Escape commands for erasing text
296
297 These commands "erase" part of the sub-buffer.
298 Erasing means replacing by white space; it is not the same as deleting.
299 The relative screen positions of things that are not erased remain
300 unchanged with each other, as does the relative cursor position.
301
302 @table @kbd
303 @item E [ J
304 Erase from cursor to end of screen.
305 @item E [ 0 J
306 Same as E [ J.
307 @item E [ 1 J
308 Erase from home position to point.
309 @item E [ 2 J
310 Erase whole sub-buffer.
311 @item E [ K
312 Erase from point to end of screen line.
313 @item E [ 0 K
314 Same as E [ K.
315 @item E [ 1 K
316 Erase from beginning of screen line to point.
317 @item E [ 2 K
318 Erase whole screen line.
319 @end table
320
321 @node Inserting and deleting
322 @subsection Escape sequences to insert and delete text
323
324 @table @kbd
325 @item Esc [ N L
326 Insert N (default 1) blank lines.
327 @item Esc [ N M
328 Delete N (default 1) lines.
329 @item Esc [ N P
330 Delete N (default 1) characters.
331 @item Esc [ N @@
332 Insert N (default 1) spaces.
333 @end table
334
335 @node Scrolling
336 @subsection Escape sequences to scroll part of the visible window
337
338 @table @kbd
339 @item Esc D
340 Scroll forward one screen line.
341
342 @item Esc M
343 Scroll backwards one screen line.
344
345 @item Esc [ T ; B r
346 Set the scrolling region to be from lines T down to line B inclusive,
347 where line 1 is the topmost line.
348 @end table
349
350 @node Command hook
351 @subsection Command hook
352
353 If @kbd{C-z} is seen, any text up to a following @key{LF} is scanned.
354 The text in between (not counting the initial C-z or the final LF)
355 is passed to the function that is the value of @code{term-command-hook}.
356
357 The default value of the @code{term-command-hook} variable
358 is the function @code{term-command-hook}, which handles the following:
359
360 @table @kbd
361 @item C-z C-z FILENAME:LINENUMBER:IGNORED LF
362 Set term-pending-frame to @code{(cons "FILENAME" LINENUMBER)}.
363 When the buffer is displayed in the current window, show
364 the FILENAME in the other window, and show an arrow at LINENUMBER.
365 Gdb emits these strings when invoked with the flag --fullname.
366 This is used by gdb mode; you can also invoke gdb with this flag
367 from shell mode.
368
369 @item C-z / DIRNAME LF
370 Set the directory of the term buffer to DIRNAME
371
372 @item C-z ! LEXPR LF
373 Read and evaluate LEXPR as a Lisp expression.
374 The result is ignored.
375 @end table
376
377 @node Miscellaneous escapes
378 @subsection Miscellaneous escapes
379
380 @table @kbd
381 @item C-g (Bell)
382 Calls @code{(beep t)}.
383
384 @item Esc 7
385 Save cursor.
386
387 @item Esc 8
388 Restore cursor.
389
390 @item Esc [ 47 h
391 Switch to the alternate sub-buffer,
392 @item Esc [ 47 l
393 Switch back to the regular sub-buffer,
394 @end table
395
396 @bye