1 This is Info file ../info/term.info, produced by Makeinfo version 1.68
2 from the input file term.texi.
4 INFO-DIR-SECTION XEmacs Editor
6 * Term mode: (term). Emacs terminal emulator mode.
10 File: term.info, Node: Top, Prev: (DIR)
12 Terminal emulator mode
13 **********************
15 This is some notes about the term Emacs mode.
22 File: term.info, Node: term mode, Prev: Top, Up: Top
30 * Connecting to remote computers::
34 The `term' package includes the major modes `term', `shell', and
35 `gud' (for running gbd or another debugger). It is a replacement for
36 the comint mode of Emacs 19, as well as shell, gdb, terminal, and
37 telnet modes. The package works best with recent releases of Emacs 19,
38 but will also work reasonably well with Emacs 18 as well as Lucid Emacs
41 The file `nshell.el' is a wrapper to use unless term mode is built
42 into Emacs. If works around some of the missing in older Emacs
43 versions. To use it, edit the paths in `nshell.el', appropriately, and
44 then `M-x load-file nshell.el RET'. This will also load in replacement
48 File: term.info, Node: Overview, Next: Connecting to remote computers, Up: term mode
53 The `term' mode is used to control a program (an "inferior process").
54 It sends most keyboard input characters to the program, and displays
55 output from the program in the buffer. This is similar to the
56 traditional comint mode, and modes derived from it (such as shell and
57 gdb modes). You can do with the new term-based shell the same sort of
58 things you could do with the old shell mode, using more or less the
59 same interface. However, the new mode is more flexible, and works
64 * Output from the inferior::
65 * subbuffer:: The sub-buffer
66 * altsubbuffer:: The alternate sub-buffer
67 * Input to the inferior::
70 File: term.info, Node: Output from the inferior, Next: subbuffer, Up: Overview
72 Output from the inferior
73 ------------------------
75 In typical usage, output from the inferior is added to the end of
76 the buffer. If needed, the window will be scrolled, just like a
77 regular terminal. (Only one line at a time will be scrolled, just like
78 regular terminals, and in contrast to the old shell mode.) Thus the
79 buffer becomes a log of your interaction with the inferior, just like
82 Like a real terminal, term maintains a "cursor position." This is
83 the `process-mark' of the inferior process. If the process-mark is not
84 at the end of the buffer, output from the inferior will overwrite
85 existing text in the buffer. This is like a real terminal, but unlike
86 the old shell mode (which inserts the output, instead of overwriting).
88 Some programs (such as Emacs itself) need to control the appearance
89 on the screen in detail. They do this by sending special control
90 codes. The exact control codes needed from terminal to terminal, but
91 nowadays most terminals and terminal emulators (including xterm)
92 understand the so-called "ANSI escape sequences" (first popularized by
93 the Digital's VT100 family of terminal). The term mode also
94 understands these escape sequences, and for each control code does the
95 appropriate thing to change the buffer so that the appearance of the
96 window will match what it would be on a real terminal. (In contrast,
97 the old shell mode doesn't handle terminal control codes at all.)
99 See <...> for the specific control codes.
102 File: term.info, Node: subbuffer, Next: altsubbuffer, Prev: Output from the inferior, Up: Overview
107 A program that talks to terminal expects the terminal to have a
108 fixed size. If the program is talking a terminal emulator program such
109 as `xterm', that size can be changed (if the xterm window is re-sized),
110 but programs still assume a logical terminal that has a fixed size
111 independent of the amount of output transmitted by the programs.
113 To programs that use it, the Emacs terminal emulator acts as if it
114 too has a fixed size. The "sub-buffer" is the part of a `term'-mode
115 buffer that corresponds to a "normal" terminal. Most of the time
116 (unless you explicitly scroll the window displaying the buffer), the
117 sub-buffer is the part of the buffer that is displayed in a window.
119 The sub-buffer is defined in terms of three buffer-local-variable:
121 - Variable: term-height
122 The height of the sub-buffer, in screen lines.
124 - Variable: term-width
125 The width of the sub-buffer, in screen columns.
127 - Variable: term-home-marker
128 The "home" position, that is the top left corner of the sub-buffer.
130 The sub-buffer is assumed to be the end part of the buffer; the
131 `term-home-marker' should never be more than `term-height' screen lines
132 from the end of the buffer.
135 File: term.info, Node: altsubbuffer, Next: Input to the inferior, Prev: subbuffer, Up: Overview
137 The alternate sub-buffer
138 ------------------------
140 When a "graphical" program finishes, it is nice to restore the
141 screen state to what it was before the program started. Many people
142 are used to this behavior from `xterm', and its also offered by the
145 - Function: term-switch-to-alternate-sub-buffer SET
146 If SET is true, and we're not already using the alternate
147 sub-buffer, switch to it. What this means is that the
148 `term-home-marker' is saved (in the variable
149 `term-saved-home-marker'), and the `term-home-marker' is set to
150 the end of the buffer.
152 If SET is false and we're using the alternate sub-buffer, switch
153 back to the saved sub-buffer. What this means is that the
154 (current, alternate) sub-buffer is deleted (using `(delete-region
155 term-home-marker (point-max))'), and then the `term-home-marker'
156 is restored (from `term-saved-home-marker').
159 File: term.info, Node: Input to the inferior, Prev: altsubbuffer, Up: Overview
161 Input to the inferior
162 ---------------------
164 Characters typed by the user are sent to the inferior. How this is
165 done depends on whether the `term' buffer is in "character" mode or
166 "line" mode. (A `term' buffer can also be in "pager" mode. This is
167 discussed <later>.) Which of these is currently active is specified in
168 the mode line. The difference between them is the key-bindings
171 In character mode, one character (by default <C-c>) is special, and
172 is a prefix for various commands. All other characters are sent
173 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.
177 In line mode, key commands mostly have standard Emacs actions.
178 Regulars characters insert themselves into the buffer. When return is
179 typed, the entire current line of the buffer (except possibly the
180 prompt) is sent to the inferior process. Line mode is basically the
181 original shell mode from earlier Emacs versions.
183 To switch from line mode to character mode type `C-c c'. To switch
184 from character mode to line mode type `C-c l'.
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 is
188 sent to the inferior, it is deleted from the buffer. This is so that
189 the inferior can echo the input, if it wishes (which it normally does).
192 File: term.info, Node: Connecting to remote computers, Next: Paging, Prev: Overview, Up: term mode
194 Connecting to remote computers
195 ==============================
197 If you want to login to a remove computer, you can do that just as
198 you would expect, using whatever commands you would normally use.
200 (This is worth emphasizing, because earlier versions of `shell' mode
201 would not work properly if you tried to log in to some other computer,
202 because of the way echoing was handled. That is why there was a
203 separate `telnet' mode to partially compensate for these problems. The
204 `telnet' mode is no longer needed, and is basically obsolete.)
206 A program that asks you for a password will normally suppress
207 echoing of the password, so the password will not show up in the buffer.
208 This will happen just as if you were using a real terminal, if the
209 buffer is in char mode. If it is in line mode, the password will be
210 temporarily visible, but will be erased when you hit return. (This
211 happens automatically; there is no special password processing.)
213 When you log in to a different machine, you need to specify the type
214 of terminal your using. If you are talking to a Bourne-compatible
215 shell, and your system understands the `TERMCAP' variable, you can use
216 the command `M-x shell-send-termcap', which sends a string specifying
217 the terminal type and size. (This command is also useful after the
218 window has changed size.)
220 If you need to specify the terminal type manually, you can try the
221 terminal types "ansi" or "vt100".
223 You can of course run gdb on that remote computer. One useful
224 trick: If you invoke gdb with the `--fullname' option, it will send
225 special commands to Emacs that will cause Emacs to pop up the source
226 files you're debugging. This will work whether or not gdb is running
227 on a different computer than Emacs, assuming can access the source
228 files specified by gdb.
231 File: term.info, Node: Paging, Next: Terminal escapes, Prev: Connecting to remote computers, Up: term mode
236 When the pager is enabled, Emacs will "pause" after each screenful
237 of output (since the last input sent to the inferior). It will enter
238 "pager" mode, which feels a lot like the "more" program: Typing a
239 space requests another screenful of output. Other commands request
240 more or less output, or scroll backwards in the `term' buffer. In
241 pager mode, type `h' or `?' to display a help message listing all the
242 available pager mode commands.
244 In either character or line mode, type `C-c p' to enable paging, and
245 `C-c D' to disable it.
248 File: term.info, Node: Terminal escapes, Prev: Paging, Up: term mode
250 Terminal Escape sequences
251 =========================
253 A program that does "graphics" on a terminal controls the terminal
254 by sending strings called "terminal escape sequences" that the terminal
255 (or terminal emulator) interprets as special commands. The `term' mode
256 includes a terminal emulator that understands standard ANSI escape
257 sequences, originally popularized by VT100 terminals, and now used by
258 the `xterm' program and most modern terminal emulator software.
262 * Cursor motion:: Escape sequences to move the cursor
263 * Erasing:: Escape commands for erasing text
264 * Inserting and deleting:: Escape sequences to insert and delete text
265 * Scrolling:: Escape sequences to scroll part of the visible window
267 * Miscellaneous escapes::
276 File: term.info, Node: Cursor motion, Next: Erasing, Up: Terminal escapes
278 Escape sequences to move the cursor
279 -----------------------------------
282 Moves to the beginning of the current screen line.
285 Moves backwards one column. (Tabs are broken up if needed.)
288 Move to screen row R, screen column C, where (R=1) is the top row,
289 and (C=1) is the leftmost column. Defaults are R=1 and C=1.
292 Move N (default 1) screen lines up.
295 Move N (default 1) screen lines down.
298 Move N (default 1) columns right.
301 Move N (default 1) columns left.
304 File: term.info, Node: Erasing, Next: Inserting and deleting, Prev: Cursor motion, Up: Terminal escapes
306 Escape commands for erasing text
307 --------------------------------
309 These commands "erase" part of the sub-buffer. Erasing means
310 replacing by white space; it is not the same as deleting. The relative
311 screen positions of things that are not erased remain unchanged with
312 each other, as does the relative cursor position.
315 Erase from cursor to end of screen.
321 Erase from home position to point.
324 Erase whole sub-buffer.
327 Erase from point to end of screen line.
333 Erase from beginning of screen line to point.
336 Erase whole screen line.
339 File: term.info, Node: Inserting and deleting, Next: Scrolling, Prev: Erasing, Up: Terminal escapes
341 Escape sequences to insert and delete text
342 ------------------------------------------
345 Insert N (default 1) blank lines.
348 Delete N (default 1) lines.
351 Delete N (default 1) characters.
354 Insert N (default 1) spaces.
357 File: term.info, Node: Scrolling, Next: Command hook, Prev: Inserting and deleting, Up: Terminal escapes
359 Escape sequences to scroll part of the visible window
360 -----------------------------------------------------
363 Scroll forward one screen line.
366 Scroll backwards one screen line.
369 Set the scrolling region to be from lines T down to line B
370 inclusive, where line 1 is the topmost line.
373 File: term.info, Node: Command hook, Next: Miscellaneous escapes, Prev: Scrolling, Up: Terminal escapes
378 If `C-z' is seen, any text up to a following <LF> is scanned. The
379 text in between (not counting the initial C-z or the final LF) is
380 passed to the function that is the value of `term-command-hook'.
382 The default value of the `term-command-hook' variable is the
383 function `term-command-hook', which handles the following:
385 `C-z C-z FILENAME:LINENUMBER:IGNORED LF'
386 Set term-pending-frame to `(cons "FILENAME" LINENUMBER)'. When
387 the buffer is displayed in the current window, show the FILENAME
388 in the other window, and show an arrow at LINENUMBER. Gdb emits
389 these strings when invoked with the flag -fullname. This is used
390 by gdb mode; you can also invoke gdb with this flag from shell
394 Set the directory of the term buffer to DIRNAME
397 Read and evaluate LEXPR as a Lisp expression. The result is
401 File: term.info, Node: Miscellaneous escapes, Prev: Command hook, Up: Terminal escapes
403 Miscellaneous escapes
404 ---------------------
416 Switch to the alternate sub-buffer,
419 Switch back to the regular sub-buffer,
425 Node: term mode
\7f393
426 Node: Overview
\7f1216
427 Node: Output from the inferior
\7f1966
428 Node: subbuffer
\7f3546
429 Node: altsubbuffer
\7f4869
430 Node: Input to the inferior
\7f5894
431 Node: Connecting to remote computers
\7f7414
433 Node: Terminal escapes
\7f9989
434 Node: Cursor motion
\7f10857
435 Node: Erasing
\7f11517
436 Node: Inserting and deleting
\7f12312
437 Node: Scrolling
\7f12702
438 Node: Command hook
\7f13148
439 Node: Miscellaneous escapes
\7f14184