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