Major bugfixes and slight enhancements.
[bpt/emacs.git] / README.multi-tty
CommitLineData
28d440ab
KL
1 -*- coding: utf-8; -*-
2GOAL
3----
4
5The ultimate goal of this branch is to implement support for opening
6multiple, different tty devices and simultaneous X and tty frames from
7a single Emacs session.
8
9WHO IS DOING IT
10---------------
11
12I'm Károly Lőrentey. My address: lorentey@elte.hu.
13
14Patches or suggestions are welcome!
15
6548cf00 16Retrieving the latest version of the branch:
4f0359de
KL
17
18 tla register-archive lorentey@elte.hu--2004 http://lorentey.web.elte.hu/arch/2004/
19 tla get lorentey@elte.hu--2004/emacs--multi-tty--0 <directory>
20
21(I use tla 1.1.)
22
28d440ab
KL
23
24STATUS
25------
26
52c2ee2a
KL
27Basic multi-tty support is there; there are some rough edges, but it
28already seems to be usable. Emacsclient has been extended to support
29opening a new terminal frame.
28d440ab 30
04c3243c
KL
31To try it out, compile the multi-tty branch with the following
32commands:
bc279d67
KL
33
34 mkdir +build
35 cd +build
36 ../configure --with-x-toolkit=no --without-x
37 make bootstrap
38
39then start up the emacs server (src/emacs, M-x server-start), and then
6548cf00 40(from a shell prompt on another terminal) start emacsclient with
28d440ab 41
16c290d8 42 lib-src/emacsclient -f /optional/file/names...
28d440ab 43
04c3243c
KL
44You'll hopefully have two fully working, independent frames on
45separate terminals. (This seems to be very useful, emacsclient starts
46up even faster than vi!) :-) You can close the newly opened frame and
47return to the shell without exiting Emacs by pressing C-x 5 0, i.e.,
48delete-frame. (Note that this does not seem to work yet on the
49original terminal.) Creating new frames on the same tty with C-x 5 2
50works exactly as before. Suspending Emacs is disabled at the moment.
51If you exit emacs, all terminals should be restored to their previous
52states.
52c2ee2a
KL
53
54X, Mac, Windows and DOS support is broken, probably doesn't even
04c3243c
KL
55compile -- this will be solved later. Please see the attached README
56for other issues, implementation notes and sub-TODO items.
57
58Only tested on my GNU/Linux box.
6548cf00 59
28d440ab
KL
60
61NEWS
62----
63
64For the NEWS file:
65
66** Support for multiple terminal devices has been added. You can
67 specify a terminal device (`tty' parameter) and a terminal type
6548cf00 68 (`tty-type' parameter) to `make-terminal-frame'. `tty' must be a
52c2ee2a 69 terminal device created by the updated emacsclient, or there will
0a125897 70 be problems with terminal input and window resizes.
6548cf00
KL
71
72 You can test for the presence of multiple terminal support by
73 testing for the `multi-tty' feature.
74
75** A make-frame-on-tty function has been added to make it easier to
76 create frames on new terminals.
28d440ab 77
9628b887
KL
78** Emacsclient has been extended to support opening a new terminal
79 frame.
28d440ab
KL
80
81CHANGELOG
82---------
83
84See arch logs.
85
86
6548cf00
KL
87DIARY OF CHANGES
88----------------
89
90(ex-TODO items with explanations.)
28d440ab
KL
91
92-- Introduce a new abstraction for terminal devices.
93
94 (Done, see struct tty_output. The abstraction is not yet
95 complete.)
96
28d440ab
KL
97-- Change the bootstrap procedure to initialize tty_list.
98
99 (Done, but needs review.)
100
28d440ab
KL
101-- Change make-terminal-frame to support specifying another tty.
102
103 (Done, new frame parameters: `tty' and `tty-type'.)
104
9628b887
KL
105-- Implement support for reading from multiple terminals.
106
107 (Done, read_avail_input tries to read from each terminal, until one
6548cf00
KL
108 succeeds. MULTIKBOARD is not used. Secondary terminals don't send
109 SIGIO!)
9628b887
KL
110
111-- other-frame should cycle through the frames on the `current'
6548cf00 112 terminal only.
9628b887 113
6548cf00 114 (Done, by trivially modifiying next_frame and prev_frame.)
9628b887
KL
115
116-- Support different terminal sizes.
117
118 (Done, no problem.)
119
120-- Make sure terminal resizes are handled gracefully. (Could be
121 problematic.)
122
6548cf00
KL
123 (Done. We don't get automatic SIGWINCH for additional ttys,
124 though.)
9628b887
KL
125
126-- Extend emacsclient to automatically open a new tty when it connects
127 to Emacs.
128
129 (Done. It's an ugly hack, needs more work.)
130
52c2ee2a
KL
131-- Redisplay must refresh the topmost frame on *all* terminals, not
132 just the initial terminal.
9628b887 133
52c2ee2a 134 (Done, but introduced an ugly redisplay problems. Ugh.)
9628b887 135
6548cf00
KL
136-- Fix redisplay problems.
137
52c2ee2a
KL
138 (Done; it turned out that the entire Wcm structure must be moved
139 inside tty_output. Why didn't I catch this earlier?)
6548cf00
KL
140
141-- Provide a way for emacsclient to tell Emacs that the tty has been
142 resized.
143
144 (Done, simply forward the SIGWINCH signal.)
145
146-- Each keypress should automatically select the frame corresponding
147 to the terminal that it was coming from. This means that Emacs
148 must know from which terminal the last keyboard event came from.
6548cf00 149
52c2ee2a
KL
150 (Done, it was quite simple, the input event system already
151 supported multiple frames.)
6548cf00
KL
152
153-- Fix SIGIO issue with secondary terminals.
154
155 (Done, emacsclient signals Emacs after writing to the proxy pseudo
52c2ee2a
KL
156 terminal. Note that this means that multi-tty does not work with
157 raw ttys!)
28d440ab 158
0a125897
KL
159 (Update: This is bullshit. There is a read_input_waiting function,
160 extend that somehow.)
161
fca177d4
KL
162-- Make make-terminal-frame look up the `tty' and `tty-type' frame
163 parameters from the currently selected terminal before the global
164 default.
165
166 (Done.)
167
168-- Put all cached terminal escape sequences into struct tty_output.
169 Currently, they are still stored in global variables, so we don't
170 really support multiple terminal types.
171
52c2ee2a 172 (Done. It was not fun.)
fca177d4
KL
173
174-- Implement sane error handling after initialization. (Currently
6548cf00
KL
175 emacs exits if you specify a bad terminal type.) The helpful error
176 messages must still be provided when Emacs starts.
177
fca177d4
KL
178 (Done.)
179
180-- Implement terminal deletion, i.e., deleting local frames, closing
181 the tty device and restoring its previous state without exiting
182 Emacs.
9628b887 183
fca177d4
KL
184 (Done, but at the moment only called when an error happens during
185 initialization. There is a memory corruption error around this
186 somewhere.)
187
8303ba32
KL
188-- Implement automatic deletion of terminals when the last frame on
189 that terminal is closed.
190
191 (Done.)
192
0a125897
KL
193-- Restore tty screen after closing the terminal.
194
195 (Done, we do the same as Emacs 21.2 for all terminals.)
196
197-- 'TERM=dumb src/emacs' does not restore the terminal state.
198
199 (Done.)
fca177d4 200
b2af72d2
KL
201-- C-g should work on secondary terminals.
202
203 (Done, but the binding is not configurable.)
204
205-- Deal with SIGHUP in Emacs and in emacsclient. (After this, the
206 server-frames may be removed from server.el.)
207
208 (Done, nothing to do. It seems that Emacs does not receive SIGHUP
209 from secondary ttys.)
210
211-- Change emacsclient/server.el to support the -h argument better,
212 i.e. automatically close the socket when the frame is closed.
213
214 (Seems to be working OK.)
215
16c290d8 216-- Fix mysterious memory corruption error with tty deletion. To
fca177d4
KL
217 trigger it, try the following shell command:
218
219 while true; do TERM=no-such-terminal-definition emacsclient -h; done
220
221 Emacs usually dumps core after a few dozen iterations. (The bug
222 seems to be related to the xfree()ing or bzero()ing of
9d9f1812
KL
223 tty_output.Wcm. Maybe there are outside references to struct Wcm?
224 Why were these vars collected into a struct before multi-tty
225 support?)
fca177d4 226
16c290d8
KL
227 (Done. Whew. It turned out that the problem had nothing to do
228 with hypothetical external references to Wcm, or any other
229 tty_output component; it was simply that delete_tty closed the
230 filehandles of secondary ttys twice, resulting in fclose doubly
231 free()ing memory. Utterly trivial matter. I love the C's memory
232 management, it puts hair on your chest.)
233
234THINGS TO DO
235------------
fca177d4 236
16c290d8
KL
237** Understand Emacs's low-level input system (it seems complicated) :-)
238 and maybe rewrite multi-tty input in terms of MULTIKBOARD.
c1c63edb 239
c33d2d42 240** Find out why does Emacs abort when it wants to close its
0a125897 241 controlling tty. Hint: chan_process[] array. Hey, maybe
16c290d8
KL
242 noninterrupt-IO would work, too? Update: no, there is no process
243 for stdin/out.
c33d2d42 244
0a125897
KL
245** Support raw secondary terminals. (Note that SIGIO works only on
246 the controlling terminal.) Hint: extend read_input_waiting() for
247 multiple ttys and hopefully this will be fixed.
6548cf00
KL
248
249** What does interrupt_input do? I tried to disable it for raw
52c2ee2a 250 secondary tty support, but it does not seem to do anything useful.
6548cf00 251
0a125897
KL
252** Issue with SIGIO: it needs to be disabled during redisplay. See if
253 fcntl() kernel behaviour could be emulated by emacsclient.
254
16c290d8
KL
255** Get rid of the accessor macros in termchar.h, or define macros for
256 all members.
257
22de1e79
KL
258** Make parts of struct tty_output accessible from Lisp. The device
259 name and the type is sufficient.
260
16c290d8
KL
261** server.el: There are issues with saving files in buffers of closed
262 clients. Try editing a file with emacsclient -f, and (without
263 saving it) do a delete-frame. The frame is closed without
264 question, and a surprising confirmation prompt appears in another
265 frame.
266
267** emacsclient.el, server.el: Handle eval or file open errors when
268 doing -f.
269
22de1e79
KL
270** Export delete_tty to the Lisp environment, for emacsclient.
271
272** Make sure C-g goes to the right frame. This is hard, as SIGINT
273 doesn't have a tty parameter. :-(
274
275** Implement support for starting an interactive Emacs session without
276 an initial frame. (The user would connect to it and open frames
277 later, with emacsclient.) Not necessarily a good idea.
278
52c2ee2a
KL
279** Move optimalization parameters (costs) from union output_data to
280 a backend-neutral per-device structure.
28d440ab 281
c33d2d42
KL
282** Find out the best way to support suspending Emacs with multiple
283 ttys.
284
c1c63edb 285** Do tty output through term_hooks, like graphical display backends.
6548cf00 286
52c2ee2a
KL
287** Fix X support.
288
c1c63edb
KL
289** Allow simultaneous X and tty frames. (Handling input could be
290 tricky.)
28d440ab
KL
291
292** Fix Mac support (I can't do this myself).
293
294** Fix W32 support (I can't do this myself).
295
296** Fix DOS support (I can't do this myself).
297
16c290d8 298** Do a grep on XXX and ?? for more issues.
28d440ab
KL
299
300;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d