Buildchain fixes and updates from Sebastian
[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&nb