5 The ultimate goal of this branch is to implement support for opening
6 multiple, different tty devices and simultaneous X and tty frames from
7 a single Emacs session.
12 I'm Károly Lőrentey. My address: lorentey@elte.hu.
14 Patches or suggestions are welcome!
16 Retrieving the latest version of the branch:
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>
27 Basic multi-tty support is there; there are some rough edges, but it
28 already seems to be usable. Emacsclient has been extended to support
29 opening a new terminal frame.
31 To try it out, compile the multi-tty branch with the following
36 ../configure --with-x-toolkit=no --without-x
39 then start up the emacs server (src/emacs, M-x server-start), and then
40 (from a shell prompt on another terminal) start emacsclient with
42 lib-src/emacsclient -h /optional/file/names...
44 You'll hopefully have two fully working, independent frames on
45 separate terminals. (This seems to be very useful, emacsclient starts
46 up even faster than vi!) :-) You can close the newly opened frame and
47 return to the shell without exiting Emacs by pressing C-x 5 0, i.e.,
48 delete-frame. (Note that this does not seem to work yet on the
49 original terminal.) Creating new frames on the same tty with C-x 5 2
50 works exactly as before. Suspending Emacs is disabled at the moment.
51 If you exit emacs, all terminals should be restored to their previous
54 X, Mac, Windows and DOS support is broken, probably doesn't even
55 compile -- this will be solved later. Please see the attached README
56 for other issues, implementation notes and sub-TODO items.
58 Only tested on my GNU/Linux box.
66 ** Support for multiple terminal devices has been added. You can
67 specify a terminal device (`tty' parameter) and a terminal type
68 (`tty-type' parameter) to `make-terminal-frame'. `tty' must be a
69 terminal device created by the updated emacsclient, or there will
70 be problems with terminal input and window resizes.
72 You can test for the presence of multiple terminal support by
73 testing for the `multi-tty' feature.
75 ** A make-frame-on-tty function has been added to make it easier to
76 create frames on new terminals.
78 ** Emacsclient has been extended to support opening a new terminal
90 (ex-TODO items with explanations.)
92 -- Introduce a new abstraction for terminal devices.
94 (Done, see struct tty_output. The abstraction is not yet
97 -- Change the bootstrap procedure to initialize tty_list.
99 (Done, but needs review.)
101 -- Change make-terminal-frame to support specifying another tty.
103 (Done, new frame parameters: `tty' and `tty-type'.)
105 -- Implement support for reading from multiple terminals.
107 (Done, read_avail_input tries to read from each terminal, until one
108 succeeds. MULTIKBOARD is not used. Secondary terminals don't send
111 -- other-frame should cycle through the frames on the `current'
114 (Done, by trivially modifiying next_frame and prev_frame.)
116 -- Support different terminal sizes.
120 -- Make sure terminal resizes are handled gracefully. (Could be
123 (Done. We don't get automatic SIGWINCH for additional ttys,
126 -- Extend emacsclient to automatically open a new tty when it connects
129 (Done. It's an ugly hack, needs more work.)
131 -- Redisplay must refresh the topmost frame on *all* terminals, not
132 just the initial terminal.
134 (Done, but introduced an ugly redisplay problems. Ugh.)
136 -- Fix redisplay problems.
138 (Done; it turned out that the entire Wcm structure must be moved
139 inside tty_output. Why didn't I catch this earlier?)
141 -- Provide a way for emacsclient to tell Emacs that the tty has been
144 (Done, simply forward the SIGWINCH signal.)
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.
150 (Done, it was quite simple, the input event system already
151 supported multiple frames.)
153 -- Fix SIGIO issue with secondary terminals.
155 (Done, emacsclient signals Emacs after writing to the proxy pseudo
156 terminal. Note that this means that multi-tty does not work with
159 (Update: This is bullshit. There is a read_input_waiting function,
160 extend that somehow.)
162 -- Make make-terminal-frame look up the `tty' and `tty-type' frame
163 parameters from the currently selected terminal before the global
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.
172 (Done. It was not fun.)
174 -- Implement sane error handling after initialization. (Currently
175 emacs exits if you specify a bad terminal type.) The helpful error
176 messages must still be provided when Emacs starts.
180 -- Implement terminal deletion, i.e., deleting local frames, closing
181 the tty device and restoring its previous state without exiting
184 (Done, but at the moment only called when an error happens during
185 initialization. There is a memory corruption error around this
188 -- Implement automatic deletion of terminals when the last frame on
189 that terminal is closed.
193 -- Restore tty screen after closing the terminal.
195 (Done, we do the same as Emacs 21.2 for all terminals.)
197 -- 'TERM=dumb src/emacs' does not restore the terminal state.
201 -- C-g should work on secondary terminals.
203 (Done, but the binding is not configurable.)
205 -- Deal with SIGHUP in Emacs and in emacsclient. (After this, the
206 server-frames may be removed from server.el.)
208 (Done, nothing to do. It seems that Emacs does not receive SIGHUP
209 from secondary ttys.)
211 -- Change emacsclient/server.el to support the -h argument better,
212 i.e. automatically close the socket when the frame is closed.
214 (Seems to be working OK.)
219 ** Fix mysterious memory corruption error with tty deletion. To
220 trigger it, try the following shell command:
222 while true; do TERM=no-such-terminal-definition emacsclient -h; done
224 Emacs usually dumps core after a few dozen iterations. (The bug
225 seems to be related to the xfree()ing or bzero()ing of
226 tty_output.Wcm or some other tty_output part. Maybe there are
227 outside references to struct Wcm? Why were these vars collected
228 into a struct before multi-tty support?)
230 The bug does not seem to happen if the error occurs before terminal
231 initialization or if I comment out all xfree()s in delete_frame.
232 Update: yes it does, although it is much rarer. Or maybe it's
235 ** Make parts of struct tty_output accessible from Lisp. The device
236 name and the type is sufficient.
238 ** Export delete_tty to the Lisp environment, for emacsclient.
240 ** Make sure C-g goes to the right frame. This is hard, as SIGINT
241 doesn't have a tty parameter. :-(
243 ** Find out why does Emacs abort when it wants to close its
244 controlling tty. Hint: chan_process[] array. Hey, maybe
245 noninterrupt-IO would work, too?
247 ** Implement support for starting an interactive Emacs session without
248 an initial frame. (The user would connect to it and open frames
249 later, with emacsclient.) Not necessarily a good idea.
251 ** Support raw secondary terminals. (Note that SIGIO works only on
252 the controlling terminal.) Hint: extend read_input_waiting() for
253 multiple ttys and hopefully this will be fixed.
255 ** What does interrupt_input do? I tried to disable it for raw
256 secondary tty support, but it does not seem to do anything useful.
258 ** Issue with SIGIO: it needs to be disabled during redisplay. See if
259 fcntl() kernel behaviour could be emulated by emacsclient.
261 ** Move optimalization parameters (costs) from union output_data to
262 a backend-neutral per-device structure.
264 ** Find out the best way to support suspending Emacs with multiple
267 ** Do tty output through term_hooks, like all other display backends.
271 ** Allow simultaneous X and tty frames.
273 ** Fix Mac support (I can't do this myself).
275 ** Fix W32 support (I can't do this myself).
277 ** Fix DOS support (I can't do this myself).
281 ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d