Fix stupid syntax errors in previous patch.
[emacs.git] / README.multi-tty
blob1dc75afb390fb254366683948b5cecf6c702449f
1                         -*- coding: utf-8; mode: text; -*-
2 GOAL
3 ----
5 This branch implements support for opening multiple, different tty
6 devices and simultaneous X and tty frames from a single Emacs session.
8 Some use cases:
9 Emacs is notoriously slow at startup, so most people use another
10 editor or emacsclient for quick editing jobs from the console.
11 Unfortunately, emacsclient was very awkward to use, because it did not
12 support opening a new Emacs frame on the current virtual console.
13 Now, with multi-tty support, it can do that.  (Emacsclient starts up
14 faster than vi!)
16 Some Gnus users (including me) run Gnus in an X frame in its own Emacs
17 instance, which they typically leave running for weeks.  It would be
18 nice if they could connect to this instance from a remote ssh session
19 and check their messages without opening a remote X frame or resorting
20 to gnus-slave.
22 WHO IS DOING IT
23 ---------------
25 I'm Károly Lőrentey.  My address: lorentey@elte.hu.
27 Comments, bug reports, suggestions and patches are welcome; send them
28 to multi-tty@lists.fnord.hu.
30 The following is a (sadly incomplete) list of people who have
31 contributed to the project by testing, submitting patches, bug
32 reports, and suggestions.  Thanks!
34 ARISAWA Akihiro <ari at mbf dot ocn dot ne dot jp>
35 Vincent Bernat <bernat at luffy dot cx>
36 Han Boetes <han at mijncomputer dot nl>
37 Robert J. Chassell <bob at rattlesnake dot com>
38 Romain Francoise <romain at orebokech dot com>
39 Ami Fischman <ami at fischman dot org>
40 Friedrich Delgado Friedrichs <friedel at nomaden dot org>
41 IRIE Tetsuya <irie at t dot email dot ne dot jp>
42 Yoshiaki Kasahara <kasahara at nc dot kyushu-u dot ac dot jp>
43 Jurej Kubelka <Juraj dot Kubelka at email dot cz>
44 David Lichteblau <david at lichteblau dot com>
45 Xavier Mallard <zedek at gnu-rox dot org>
46 Istvan Marko <mi-mtty at kismala dot com>
47 Ted Morse <morse at ciholas dot com>
48 Dan Nicolaescu <dann at ics dot uci dot edu>
49 Gergely Nagy <algernon at debian dot org>
50 Mark Plaksin <happy at mcplaksin dot org>
51 Francisco Borges <borges at let dot rug dot nl>
52 Frank Ruell <stoerte at dreamwarrior dot net>
53 Dan Waber <dwaber at logolalia dot com>
54 and many others.
56 Richard Stallman was kind enough to review an earlier version of my
57 patches.
60 MAILING LISTS
61 -------------
63 The multi-tty mailing list (discussion & bug reports):
65         Address:        multi-tty@lists.fnord.hu
66         Signup:         http://lists.fnord.hu/mailman/listinfo/multi-tty
67         Archive:        http://news.gmane.org/gmane.emacs.multi-tty/
69 Commit notifications (read-only):
71         Address:        multi-tty-commits@lists.fnord.hu
72         Signup:         http://lists.fnord.hu/mailman/listinfo/multi-tty-commits
75 STATUS
76 ------
78 The branch is now very stable and almost full-featured.  All of the
79 major problems have been fixed, only a few minor issues remain.  (It
80 still needs to be ported to Windows/Mac/DOS, though.)  Both multiple
81 tty device support and simultaneous X and tty frame support works
82 fine.  Emacsclient has been extended to support opening new tty and X
83 frames.  It has been changed open new Emacs frames by default.
85 The multi-tty branch has been scheduled for inclusion in the next
86 major release of Emacs (version 22).  I expect the merge into the
87 development trunk to occur sometime during next year (2005), after the
88 merge of the Unicode branch.
90 Tested on GNU/Linux, Solaris 8, FreeBSD and OpenBSD.  Please let me
91 know if you succeed or fail to use it on other platforms---I'll have a
92 few tricky test cases for you.
94 Known problems:
96         * The single-kboard mode.
98           If your multi-tty Emacs session seems to be frozen, you
99           probably have a recursive editing session or a pending
100           minibuffer prompt (which is a kind of recursive editing) on
101           another display.  To unfreeze your session, switch to that
102           display and complete the recursive edit, for example by
103           pressing C-] (`abort-recursive-edit').
105           I am sorry to say that currently there is no way to break
106           out of this "single-kboard mode" from a frozen display.  If
107           you are unable to switch to the display that locks the
108           others (for example because it is on a remote computer),
109           then you can use emacsclient to break out of all recursive
110           editing sessions:
112                 emacsclient -e '(top-level)'
114           Note that this (perhaps) unintuitive behaviour is by design.
115           Single-kboard mode is required because of an intrinsic Emacs
116           limitation that is very hard to eliminate.  (This limitation
117           is related to the single-threaded nature of Emacs.)
119           I plan to implement better user notification and support for
120           breaking out of single-kboard mode from locked displays.
122         * Mac, Windows and DOS support is broken, doesn't even
123           compile.  Multiple display support will probably not provide
124           new Emacs features on these systems, but the multi-tty
125           branch changed a few low-level interfaces, and the
126           system-dependent source files need to be adapted
127           accordingly.  The changes are mostly trivial, so almost
128           anyone can help, if only by compiling the branch and
129           reporting the compiler errors.  (It is not worth to do this
130           yet, though.)
133 HOW TO GET THE BRANCH
134 ---------------------
136 The branch uses GNU Arch (http://www.gnuarch.org) for version control.
138 Retrieving the latest version of the branch:
140         tla register-archive -f http://lorentey.hu/arch/2004/
141         tla get lorentey@elte.hu--2004/emacs--multi-tty <directory>
143 This incantation uses my private archive mirror that is hosted on a
144 relatively low-bandwidth site; if you are outside Hungary, you will
145 probably want to you use the Arch supermirror instead: (Note that the
146 -f option will overwrite the archive location if you have previously
147 registered the Hungarian one.)
149         tla register-archive -f http://mirrors.gnuarch.org/lorentey@elte.hu--2004/
150         tla get lorentey@elte.hu--2004/emacs--multi-tty <directory>
152 My GPG key id is 0FB27A3F; it is available from
153 hkp://wwwkeys.eu.pgp.net/, or from my homepage at
154 http://lorentey.hu/rolam/gpg.html)
156 Don't worry if the above checkout takes a few minutes to complete;
157 once you have a source tree, updating it to the latest revision will
158 be _much_ faster.  Use the following command for the update:
160         tla replay
162 You can find more information about Arch on http://wiki.gnuarch.org/.
163 It's a wonderful source control system, I highly recommend it.
165 If you don't have tla, the branch has a homepage from which you can
166 download conventional patches against Emacs CVS HEAD:
168         http://lorentey.hu/project/emacs.html
171 COMPILATION
172 -----------
174 The multi-tty branch is compiled the same way as Emacs itself:
176         make maintainer-clean  # (If you have compiled Emacs before)
178         ./configure <your favourite options>
179         make bootstrap
180         make install
182 If you have strange compilation errors, they may be caused by old
183 *.elc files that are left over from an earlier bootstrap.  The `make
184 maintainer-clean' target deletes them, so it is a good idea to run
185 that before reporting a bug.  (Emacs requires a clean recompilation
186 after certain kinds of source code changes.)
188 TESTING
189 -------
191 To test the multi-tty branch, start up the Emacs server with the
192 following commands:
194         emacs
195         M-x server-start
197 and then (from a shell prompt on another terminal) start emacsclient
198 with
199         emacsclient -t /optional/file/names...   (for a tty frame)
200         emacsclient /optional/file/names...      (for an X frame)
202 (Make sure both emacs and emacsclient are multi-tty versions.)
203 You'll hopefully have two fully working, independent frames on
204 separate terminals. The new frame is closed automatically when you
205 finish editing the specified files (C-x #), but delete-frame (C-x 5 0)
206 also works.  Of course, you can create frames on more than two tty
207 devices.
209 Creating new frames on the same tty with C-x 5 2 works, and they
210 behave the same way as in previous Emacs versions.  If you exit emacs,
211 all terminals should be restored to their previous states.
213 This is work in progress, and probably full of bugs.  It is a good
214 idea to run emacs from gdb, so that you'll have a live instance to
215 debug if something goes wrong.  Please send me your bug reports on our
216 mailing list: multi-tty@lists.fnord.hu
218 TIPS & TRICKS
219 -------------
221 I think the best way to use the new Emacs is to have it running inside
222 a disconnected GNU screen session, and always use emacsclient for
223 normal work.  One advantage of this is that not a single keystroke of
224 your work will be lost if the display device that you are using
225 crashes, or the network connection times out, or whatever.  (I had an
226 extremely unstable X server for some time while I was developing these
227 patches, and running Emacs this way has saved me a number of M-x
228 recover-session invocations.)
230 I use the following two bash functions to handle my Emacs sessions:
232 ,----[ ~/.bash_profile
233 | # Usage: preload-emacs <name> [<waitp>]
234 | #
235 | # Preloads the Emacs instance called NAME in a detached screen
236 | # session.  Does nothing if the instance is already running.  If WAITP
237 | # is non-empty, the function waits until the server starts up and
238 | # creates its socket; otherwise it returns immediately.
239 | function preload-emacs {
240 |     local name="$1"
241 |     local waitp="$2"
242 |     local screendir="/var/run/screen/S-$USER"
243 |     local serverdir="/tmp/emacs$UID"
244 |     local emacs=emacs # Or wherever you installed your multi-tty Emacs
246 |     if [ -z "$name" ]; then 
247 |       echo "Usage: preload-emacs <name> [<waitp>]" >&2
248 |       return 1
249 |     fi
251 |     if [ ! -e "$screendir"/*."$name" ]; then
252 |       if [ -e "$serverdir/$name" ]; then
253 |           # Delete leftover socket (for the wait option)
254 |           rm "$serverdir/$name"
255 |       fi
256 |       screen -dmS "$name" "$emacs" -nw --eval "(setq server-name \"$name\")" -f server-start
257 |     fi
258 |     if [ ! -z "$waitp" ]; then
259 |       while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done
260 |     fi
261 |     return 0
262 | }
264 | # Usage: connect-emacs <name> <args>...
265 | #
266 | # Connects to the Emacs instance called NAME.  Starts up the instance
267 | # if it is not already running.  The rest of the arguments are passed
268 | # to emacsclient.
269 | function connect-emacs {
270 |     local name="$1"
271 |     shift
272 |     
273 |     if [ -z "$name" ]; then
274 |       echo "Usage: connect-emacs <name> <args>..." >&2
275 |     fi
276 |     preload-emacs "$name" wait
277 |     emacsclient -s "$name" "$@"
278 | }
280 | export -f preload-emacs connect-emacs
282 | # Preload editor and gnus sessions for speedy initial connects.
283 | preload-emacs editor
284 | preload-emacs gnus
285 `----
287 ,----[ ~/.bashrc
288 | alias gnus="connect-emacs gnus"
289 | alias edit="connect-emacs editor"
290 | alias et="connect-emacs editor -t"
291 | alias e=edit
292 `----
295 NEWS
296 ----
298 For the NEWS file:  (Needs work)
300 ** Support for multiple terminal devices has been added.
302 *** You can specify a terminal device (`tty' parameter) and a terminal
303     type (`tty-type' parameter) to `make-terminal-frame'.
305 *** You can test for the presence of multiple terminal support by
306     testing for the `multi-tty' feature.
308 *** Emacsclient has been extended to support opening a new terminal
309     frame. Its behaviour has been changed to open a new Emacs frame by
310     default.  Use the -c option to get the old behavior of opening
311     files in the currently selected Emacs frame.
313 *** A make-frame-on-tty function has been added to make it easier to
314     create frames on new terminals.
316 *** New functions: frame-tty-name, frame-tty-type for accessing
317     terminal parameters, and delete-tty for closing the terminal
318     device.
320 *** talk.el has been extended for multiple tty support.
323 ** Support for simultaneous graphical and terminal frames has been
324    added.
326 *** The function `make-frame-on-display' now works during a terminal
327     session, and `make-frame-on-tty' works during a graphical session.
329 *** The `window-system' variable has been made frame-local.
331 *** The new `initial-window-system' variable contains the
332     `window-system' value for the first frame.
334 CHANGELOG
335 ---------
337 See arch logs.
339 * * *
341 (The rest of this file consists of my development notes and as such it
342 is probably not very interesting for anyone else.)
344 THINGS TO DO
345 ------------
347 ** The single-keyboard mode of MULTI_KBOARD is extremely confusing
348    sometimes; Emacs does not respond to stimuli from other keyboards.
349    At least a beep or a message would be important, if the single-mode
350    is still required to prevent interference.  (Reported by Dan
351    Nicolaescu.)  
353    Update: selecting a region with the mouse enables single_kboard
354    under X.  This is very confusing.
356    Update: After discussions with Richard, this will be resolved by
357    having locked displays warn the user to wait, and introducing a
358    complex protocol to remotely bail out of single-kboard mode by
359    pressing C-g.
361    Update: Warning the user is not trivial to implement, as Emacs has
362    only one echo area.  Ideally the warning should not be displayed on
363    the display that is locking the others.  Perhaps the high
364    probability of user confusion caused by single_kboard mode deserves
365    a special case in the display code.  Alternatively, it might be
366    good enough to signal single_kboard mode by changing the modelines
367    or some other frame-local display element on the locked out displays.
369 ** normal-erase-is-backspace-mode in simple.el needs to be updated for
370    multi-tty (rep. by Dan Waber).
372 ** Hunt down display-related functions in frame.el and extend them all
373    to accept display ids.
375 ** rif->flush_display_optional (NULL) calls should be replaced by a
376    new global function.
378 ** Have a look at fatal_error_hook.
380 ** Have a look at set_frame_matrix_frame.
382 ** Check if we got term-setup-hook right.
384 ** I think tip_frame should be display-local.
386 ** Check display reference count handling in x_create_tip_frame.
388 ** make-frame does not correctly handle extra parameters in its
389    argument:
391         (frame-parameter (make-frame (list (cons 'foobar 42))) 'foobar)
392                 => nil
394    (This is likely an error in the CVS trunk.)
396 ** Fix set-input-mode for multi-tty.  It's a truly horrible interface;
397    what if we'd blow it up into several separate functions (with a
398    compatibility definition)?
400 ** The terminal customization files in term/*.el tend to change global
401    parameters, which may confuse Emacs with multiple displays.  Change
402    them to tweak only frame-local settings, if possible.
404 ** Dan Nicolaescu suggests that -nw should be added as an alias for -t
405    in emacsclient.  Good idea.  (Alas, implementing this is not
406    trivial, getopt_long does not seem to support two-letter ``short''
407    options.  Patches are welcome.) :-)
409 ** Mark Plaksin suggests that emacsclient should accept the same
410    X-related command-line arguments as Emacs.  Most of the X-related
411    argument-handling is done in Lisp, so this should be quite easy to
412    implement.
414 ** Gergely Nagy suggests that C-x # should only kill the current
415    frame, not any other emacsclient frame that may have the same file
416    opened for editing.  I think I agree with him.
418 ** Very strange bug: visible-bell does not work on secondary
419    terminals in xterm and konsole.  The screen does flicker a bit,
420    but it's so quick it isn't noticable.
422 ** Clean up the frame-local variable system.  I think it's ugly and
423    error-prone.  But maybe I just haven't yet fully understood it.
425 ** Move baud_rate to struct display.
427 ** Implement support for starting an interactive Emacs session without
428    an initial frame.  (The user would connect to it and open frames
429    later, with emacsclient.)
431 ** Fix Mac support (I can't do this entirely myself).  Note that the
432    current state of Mac-specific source files in the multi-tty tree
433    are not useful; before starting work on Mac support, revert to
434    pristine, pre-multi-tty versions.
436 ** Fix W32 support (I can't do this entirely myself).  Note that the
437    current state of W32-specific source files in the multi-tty tree
438    are not useful; before starting work on W32 support, revert to
439    pristine, pre-multi-tty versions.
441 ** Fix DOS support (I can't do this entirely myself).  Note that the
442    current state of DOS-specific source files in the multi-tty tree
443    are not useful; before starting work on DOS support, revert to
444    pristine, pre-multi-tty versions.
446 ** Do a grep on XXX and ?? for more issues.
448 ** Understand Emacs's low-level input system (it's black magic) :-)
449    What exactly does interrupt_input do?  I tried to disable it for
450    raw secondary tty support, but it does not seem to do anything
451    useful.  (Update: Look again. X unconditionally enables this, maybe
452    that's why raw terminal support is broken again.  I really do need
453    to understand input.)
455 ** Maybe standard-display-table should be display-local.
457 DIARY OF CHANGES
458 ----------------
460 (ex-TODO items with explanations.)
462 -- Introduce a new struct for terminal devices.
464    (Done, see struct tty_output.  The list of members is not yet
465    complete.)
467 -- Change the bootstrap procedure to initialize tty_list.
469    (Done, but needs review.)
471 -- Change make-terminal-frame to support specifying another tty.
473    (Done, new frame parameters: `tty' and `tty-type'.)
475 -- Implement support for reading from multiple terminals.
477    (Done, read_avail_input tries to read from each terminal, until one
478    succeeds.  MULTI_KBOARD is not used.  Secondary terminals don't send
479    SIGIO!)
481    (Update: They do, now.)
483    (Update2: After enabling X, they don't.)
485 -- other-frame should cycle through the frames on the `current'
486    terminal only.
488    (Done, by trivially modifiying next_frame and prev_frame.)
490 -- Support different terminal sizes.
492    (Done, no problem.)
494 -- Make sure terminal resizes are handled gracefully.  (Could be
495    problematic.)
497    (Done.  We don't get automatic SIGWINCH for additional ttys,
498    though.)
500 -- Extend emacsclient to automatically open a new tty when it connects
501    to Emacs.
503    (Done.  It's an ugly hack, needs more work.)
505 -- Redisplay must refresh the topmost frame on *all* terminals, not
506    just the initial terminal.
508    (Done, but introduced an ugly redisplay problems.  Ugh.)
510 -- Fix redisplay problems.
512    (Done; it turned out that the entire Wcm structure must be moved
513    inside tty_output.  Why didn't I catch this earlier?)
515 -- Provide a way for emacsclient to tell Emacs that the tty has been
516    resized.
518    (Done, simply forward the SIGWINCH signal.)
520 -- Each keypress should automatically select the frame corresponding
521    to the terminal that it was coming from.  This means that Emacs
522    must know from which terminal the last keyboard event came from.
524    (Done, it was quite simple, the input event system already
525    supported multiple frames.)
527 -- Fix SIGIO issue with secondary terminals.
529    (Done, emacsclient signals Emacs after writing to the proxy pseudo
530    terminal.  Note that this means that multi-tty does not work with
531    raw ttys!)
533    (Update: This is bullshit.  There is a read_input_waiting function,
534    extend that somehow.)
536    (Update of update: The first update was not right either, extending
537    read_input_waiting was not necessary.  Secondary ttys do seem to
538    send signals on input.)
540    (Update^3: Not any more.)
542 -- Make make-terminal-frame look up the `tty' and `tty-type' frame
543    parameters from the currently selected terminal before the global
544    default.
546    (Done.)
548 -- Put all cached terminal escape sequences into struct tty_output.
549    Currently, they are still stored in global variables, so we don't
550    really support multiple terminal types.
552    (Done.  It was not fun.)
554 -- Implement sane error handling after initialization.  (Currently
555    emacs exits if you specify a bad terminal type.)  The helpful error
556    messages must still be provided when Emacs starts.
558    (Done.)
560 -- Implement terminal deletion, i.e., deleting local frames, closing
561    the tty device and restoring its previous state without exiting
562    Emacs.
564    (Done, but at the moment only called when an error happens during
565    initialization.  There is a memory corruption error around this
566    somewhere.)  (Update: now it is fully enabled.)
568 -- Implement automatic deletion of terminals when the last frame on
569    that terminal is closed.
571    (Done.)
573 -- Restore tty screen after closing the terminal.
575    (Done, we do the same as Emacs 21.2 for all terminals.)
577 -- 'TERM=dumb src/emacs' does not restore the terminal state.
579    (Done.)
581 -- C-g should work on secondary terminals.
583    (Done, but the binding is not configurable.)
585 -- Deal with SIGHUP in Emacs and in emacsclient.  (After this, the
586    server-frames may be removed from server.el.)
588    (Done, nothing to do.  It seems that Emacs does not receive SIGHUP
589    from secondary ttys, which is actually a good thing.)  (Update: I
590    think it would be a bad idea to remove server-frames.)
592 -- Change emacsclient/server.el to support the -t argument better,
593    i.e. automatically close the socket when the frame is closed.
595    (Seems to be working OK.)
597 -- Fix mysterious memory corruption error with tty deletion.  To
598    trigger it, try the following shell command:
600         while true; do TERM=no-such-terminal-definition emacsclient -h; done
602    Emacs usually dumps core after a few dozen iterations.  (The bug
603    seems to be related to the xfreeing or bzeroing of
604    tty_output.Wcm.  Maybe there are outside references to struct Wcm?
605    Why were these vars collected into a struct before multi-tty
606    support?)
608    (Done.  Whew.  It turned out that the problem had nothing to do
609    with hypothetical external references to Wcm, or any other
610    tty_output component; it was simply that delete_tty closed the
611    filehandles of secondary ttys twice, resulting in fclose doubly
612    freeing memory.  Utterly trivial matter.  I love the C's memory
613    management, it puts hair on your chest.)
615 -- Support raw secondary terminals.  (Note that SIGIO works only on
616    the controlling terminal.) Hint: extend read_input_waiting for
617    multiple ttys and hopefully this will be fixed.
619    (Done, it seems to have been working already for some time.  It
620    seems F_SETOWN does work, after all.  Not sure what made it fail
621    earlier, but it seems to be fixed (there were several changes
622    around request_sigio, maybe one of them did it).
623    read_input_waiting is only used in sys_select, don't change
624    it.)  (Update: After adding X support, it's broken again.)
625    (Update^2: No it isn't.) :-)
627 -- Find out why does Emacs abort when it wants to close its
628    controlling tty.  Hint: chan_process[] array.  Hey, maybe
629    noninterrupt-IO would work, too?  Update: no, there is no process
630    for stdin/out.
632    (Done.  Added add/delete_keyboard_wait_descriptor to
633    term_init/delete_tty.  The hint was right, in a way.)
635 -- Issue with SIGIO: it needs to be disabled during redisplay.  See if
636    fcntl kernel behaviour could be emulated by emacsclient.
638    (Done.  Simply disabled the SIGIO emulation hack in emacsclient.)
639    (Update: it was added back.)  (Update^2: and removed again.)
641 -- server.el: There are issues with saving files in buffers of closed
642    clients.  Try editing a file with emacsclient -f, and (without
643    saving it) do a delete-frame.  The frame is closed without
644    question, and a surprising confirmation prompt appears in another
645    frame.
647    (Done.  delete-frame now asks for confirmation if it still has
648    pending buffers, and modified buffers don't seem to be deleted.)
650 -- emacsclient.el, server.el: Handle eval or file open errors when
651    doing -t.
653    (Done.)
655 -- Make parts of struct tty_output accessible from Lisp.  The device
656    name and the type is sufficient.
658    (Done, see frame-tty-name and frame-tty-type.)
660 -- Export delete_tty to the Lisp environment, for emacsclient.
662    (Done, see delete-tty.)
664 -- Get rid of the accessor macros in termchar.h, or define macros for
665    all members.
667    (Done.)
669 -- Move device-specific parameters (like costs) commonly used by
670    device backends to a common, device-dependent structure.
672    (Done.  See struct display_method in termhooks.h.)
674 -- Fix X support.
676    (Done.  Well, it seems to be working.)
678 -- Allow simultaneous X and tty frames.  (Handling input could be
679    tricky.  Or maybe not.)
681    (Done.  Allowed, that is.  It is currently extremely unstable, to
682    the point of being unusable.  The rif variable causes constant
683    core dumps.  Handling input is indeed tricky.)
685 -- Rewrite multi-tty input in terms of MULTI_KBOARD.
687    (Done.  In fact, there was no need to rewrite anything, I just
688    added a kboard member to tty_display_info, and initialized the
689    frame's kboard from there.)
691 -- Fix rif issue with X-tty combo sessions.  IMHO the best thing to do
692    is to get rid of that global variable (and use the value value in
693    display_method, which is guaranteed to be correct).
695    (Done, did exactly that.  Core dumps during combo sessions became
696    much rarer.  In fact, I have not yet met a single one.)
698 -- Add multi-tty support to talk.el.
700    (Done.)
702 -- Clean up the source of emacsclient.  It is a mess.
704    (Done, eliminated stupid proxy-pty kludge.)
706 -- Fix faces on tty frames during X-tty combo sessions.  There is an
707    init_frame_faces call in init_sys_modes, see if there is a problem
708    with it.
710    (Done, there was a stupid mistake in
711    Ftty_supports_face_attributes_p. Colors are broken, though.)
713 -- C-x 5 2, C-x 5 o, C-x 5 0 on an emacsclient frame unexpectedly
714    exits emacsclient.  This is a result of trying to be clever with
715    delete-frame-functions.
717    (Fixed, added delete-tty-after-functions, and changed server.el to
718    use it.)
720 -- Something with (maybe) multi-keyboard support broke function keys
721    and arrows on ttys during X+tty combo sessions.  Debug this.
723    (I can't reproduce it, maybe the terminal type was wrong.)
725 -- Fix input from raw ttys (again).
727    (Now it seems to work all right.)
729 -- During an X-tty combo session, a (message "Hello") from a tty frame
730    goes to the X frame.  Fix this.
732    (Done.  There was a safeguard against writing to the initial
733    terminal frame during bootstrap which prevented echo_area_display
734    from working correctly on a tty frame during a combo session.)
736 -- If there are no frames on its controlling terminal, Emacs should
737    exit if the user presses C-c there.
739    (Done, as far as possible.  See the SIGTERM comment in
740    interrupt_signal on why this seems to be impossible to solve this
741    in general.)
743 -- During an X session, Emacs seems to read from stdin.  Also, Emacs
744    fails to start without a controlling tty.
746    (Fixed by replacing the troublesome termcap display with a dummy
747    bootstrap display during bootstrap.
749 -- Do tty output through struct display, like graphical display
750    backends.
752    (Done.)
754 -- Define an output_initial value for output_method for the initial
755    frame that is dumped with Emacs.  Checking for this frame (e.g. in
756    cmd_error_internal) is ugly.
758    (Done, broking interactive temacs.)
760 -- The command `emacsclient -t -e '(delete-frame)'' fails to exit.
762    (Fixed.)
764 -- frame-creation-function should always create a frame that is on the
765    same display as the selected frame.  Maybe frame-creation-function
766    should simply be removed and make-frame changed to do the right
767    thing.
769    (Done, with a nice hack.  frame-creation-function is now frame-local.)
771 -- Fix C-g on raw ttys.
773    (Done.  I disabled the interrupt/quit keys on all secondary
774    terminals, so Emacs sees C-g as normal input.  This looks like an
775    overkill, because emacsclient has extra code to pass SIGINT to
776    Emacs, so C-g should remain the interrupt/quit key on emacsclient
777    frames.  See the next entry why implementing this distinction would
778    be a bad idea.)
780 -- Make sure C-g goes to the right frame with ttys.  This is hard, as
781    SIGINT doesn't have a tty parameter. :-(
783    (Done, the previous change fixes this as a pleasant side effect.)
785 -- I have seen a case when Emacs with multiple ttys fell into a loop
786    eating 100% of CPU time.  Strace showed this loop:
788         getpid()                                = 30284
789         kill(30284, SIGIO)                      = 0
790         --- SIGIO (I/O possible) @ 0 (0) ---
791         ioctl(6, FIONREAD, [0])                 = -1 EIO (Input/output error)
792         ioctl(5, FIONREAD, [0])                 = -1 EIO (Input/output error)
793         ioctl(0, FIONREAD, [0])                 = 0
794         sigreturn()                             = ? (mask now [])
795         gettimeofday({1072842297, 747760}, NULL) = 0
796         gettimeofday({1072842297, 747806}, NULL) = 0
797         select(9, [0 3 5 6], NULL, NULL, {0, 0}) = 2 (in [5 6], left {0, 0})
798         select(9, [0 3 5 6], NULL, NULL, {0, 0}) = 2 (in [5 6], left {0, 0})
799         gettimeofday({1072842297, 748245}, NULL) = 0
801    I have seen something similar with a single X frame, but have not
802    been able to reproduce it for debugging.
804    Update: This may have been caused by checking for nread != 0
805    instead of nread > 0 after calling read_socket_hook in
806    read_avail_input.
808    (Fixed.  This was caused by unconditionally including stdin in
809    input_wait_mask in init_process.  The select call in
810    wait_reading_process_input always returned immediately, indicating
811    that there is pending input from stdin, which nobody read.
813    Note that the above strace output seems to be an unrelated but
814    similar bug.  I think that is now fixed.)
816 -- Exiting Emacs while there are emacsclient frames doesn't restore the
817    ttys to their default states.
819    (This seems to be fixed by some previous change.)
821 -- Allow opening an X session after -nw.
823    (Done.)
825 -- Fix color handling during tty+X combo sessions.  (It seems that tty
826    sessions automatically convert the face colors to terminal colors
827    when the face is loaded.  This conversion must happen instead on
828    the fly in write_glyphs, which might be problematic, as color
829    approximation is currently done in lisp (term/tty-colors.el).)
830    (Update: hm, colors seem to work fine if I start emacs with -nw and
831    then create an X frame.  Maybe it's just a small buglet somewhere.)
833    (Seems to be fixed.  The problem was in startup.el, it did not
834    initialize tty colors when the initial window system was
835    graphical.)
837 -- emacs -nw --eval '(y-or-n-p "Foobar")' segfaults.  (Reported by
838    Romain Francoise)
840    (Fixed, there was a keyboard initialization problem.)
842 -- Fix interactive use of temacs.  There are face-related SEGVs, most
843    likely because of changes in realize_default_face, realize_face.
845    (Fixed.)
847 -- Don't exit Emacs when the last X connection fails during a
848    multi-display session.
850    (Fixed.)
852 -- Dan Nicolaescu noticed that starting emacsclient on the same
853    terminal device that is the controlling tty of the Emacs process
854    gives unexpected results.
856    (Fixed.)
858 -- Istvan Marko reported that Emacs hang on ttys if it was started
859    from a shell script.
861    (Fixed.  There was a bug in the multi-tty version of
862    narrow_foreground_group.  tcsetpgrp blocks if it is called from a
863    process that is not in the same process group as the tty.)
865 -- emacsclient -t from an Emacs term buffer does not work, complains
866    about face problems.  This can even lock up Emacs (if the recursive
867    frame sets single_kboard).  Update: the face problems are caused by
868    bugs in term.el, not in multi-tty.  The lockup is caused by
869    single_kboard mode, and is not easily resolvable.  The best thing to
870    do is to simply refuse to create a tty frame of type `eterm'.
872    (Fixed, changed emacsclient to check for TERM=eterm.  The face
873    complaints seem to be caused by bugs in term.el; they are not
874    related to multi-tty.)
876 -- Find out the best way to support suspending Emacs with multiple
877    ttys.  My guess: disable it on the controlling tty, but from other
878    ttys pass it on to emacsclient somehow.  (It is (I hope) trivial to
879    extend emacsclient to handle suspend/resume.  A `kill -STOP' almost
880    works right now.)
882    (Done.  I needed to play with signal handling and the server
883    protocol a bit to make emacsclient behave as a normal UNIX program
884    wrt foreground/background process groups.)
886 -- There is a flicker during the startup of `emacs -nw'; it's as if
887    the terminal is initialized, reset and then initialialized again.
888    Debug this.  (Hint: narrow_foreground_group is called twice during
889    startup.)
891    (This is gone.)
893 -- Robert Chassell has found serious copy-paste bugs with the
894    multi-tty branch.  There seem to be redisplay bugs while copying
895    from X to a terminal frame.  Copying accented characters do not
896    work for me.
898    (Patch-124 should fix this, by changing the interprogram-*-function
899    variables to be frame-local, as suggested by Mark Plaksin
900    (thanks!).  I think that the redisplay bugs are in fact not bugs,
901    but delays caused by single_kboard --> perhaps MULTI_KBOARD should
902    be removed.)
904 -- frame-creation-function was removed, which might be a bad idea.
905    Think up a compatible solution.
907    (It was an internal interface that may be changed when necessary.)
909 -- Change Lisp code not to (getenv "TERM"); use the `tty-type' frame
910    parameter or the frame-tty-type function instead.  (M-x tags-search
911    "TERM" helps with this.)  Update: Actually, all getenv invocations
912    should be checked for multi-tty compatibility, and an interface
913    must be implemented to get the remote client's environment.
915    (Done.  Only getenv calls in lisp/term/*.el were changed; other
916    calls should be mostly left as they are.)
918 -- Add an elaborate mechanism for display-local variables.  (There are
919    already a few of these; search for `terminal-local' in the Elisp
920    manual.)
922    (Not needed.  Display-local variables could be emulated by
923    frame-local variables.)
925 -- Emacs assumes that all terminal frames have the same locale
926    settings as Emacs itself.  This may lead to bogus results in a
927    multi-locale setup. (E.g., while logging in from a remote client
928    with a different locale.)
929    (Update after new bugreport by Friedrich Delgado Friedrichs: 
930    (at least) the structs terminal_coding and keyboard_coding in
931    coding.c must be moved to struct display, and the Lisp interface
932    [set-]keyboard-coding-system must be adapted for the change.)
934    (Fixed.  Emacs now uses the locale settings as seen by the
935    emacsclient process for server tty frames.)
938 -- Make `struct display' accessible to Lisp programs.  Accessor functions:
940         (displayp OBJECT):  Returns t if OBJECT is a display.
941                 => Implemented as display-live-p.
943         (display-list):  Returns list of currently active displays.
944                 => Implemented.
946         (selected-display):  Returns the display object of the selected frame.
947                 => Not strictly necessary, but implemented anyway.
949         (frame-display FRAME):  Returns the display object of FRAME.
950                 => Implemented.
952         (display-frames DISPLAY):  Returns a list of frames on DISPLAY.
953                 => Already implemented, see frames-on-display-list.
955         (display-type DISPLAY):  Returns the type of DISPLAY, as a
956                 symbol.  (See `framep'.)
957                 => Implemented as display-live-p.
959         (display-device DISPLAY): Returns the name of the device that
960                 DISPLAY uses, as a string.  (E.g: "/dev/pts/16", or
961                 ":0.0")
962                 => Implemented as display-name.
964         etc.
966    See next issue why this is necessary.
968    (Update: The consensus on emacs-devel seems to be to do this via
969    integer identifiers.  That's fine by me.)
971    (Done.)
973 -- The following needs to be supported:
975         $ emacsclient -t
976                 C-z
977         $ emacsclient -t
978                 (This fails now.)
980    The cleanest way to solve this is to allow multiple displays on the
981    same terminal device; each new emacsclient process should create
982    its own display.  As displays are currently identified by their
983    device names, this is not possible until struct display becomes
984    accessible as a Lisp-level object.
986    (Done.)
988 -- Miles Bader suggests that C-x C-c on an emacsclient frame should
989    only close the frame, not exit the entire Emacs session.  Update:
990    see above for a function that does this.  Maybe this should be the
991    new default?  
993    (Done.  This is the new default.  No complaints so far.)
996 ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d