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