Merged from emacs@sv.gnu.org
[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
6ed8eeff 12support opening a new Emacs frame on the current virtual tty.
7b00d185
KL
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
d6805803 34Bernard Adrian <bernadrian@free.fr>
256c9c3a
KL
35ARISAWA Akihiro <ari@mbf.ocn.ne.jp>
36Vincent Bernat <bernat@luffy.cx>
37Han Boetes <han@mijncomputer.nl>
bedeffcf 38Francisco Borges <borges@let.rug.nl>
d6805803 39Damien Cassou <damien.cassou@laposte.net>
256c9c3a
KL
40Robert J. Chassell <bob@rattlesnake.com>
41Romain Francoise <romain@orebokech.com>
42Ami Fischman <ami@fischman.org>
43Friedrich Delgado Friedrichs <friedel@nomaden.org>
44IRIE Tetsuya <irie@t.email.ne.jp>
45Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp>
46Bas Kok <nekkobassu@yahoo.com>
47Jurej Kubelka <Juraj.Kubelka@email.cz>
48David Lichteblau <david@lichteblau.com>
911650d2 49mace <mace@kirjakaapeli.lib.hel.fi>
db9d7d9a 50Suresh Madhu <madhu@cs.unm.edu>
256c9c3a
KL
51Xavier Mallard <zedek@gnu-rox.org>
52Istvan Marko <mi-mtty@kismala.com>
53Ted Morse <morse@ciholas.com>
54Gergely Nagy <algernon@debian.org>
55Dan Nicolaescu <dann@ics.uci.edu>
56Kalle Olavi Niemitalo <kon@iki.fi>
57Mark Plaksin <happy@mcplaksin.org>
256c9c3a 58Frank Ruell <stoerte@dreamwarrior.net>
bedeffcf 59Tom Schutzer-Weissmann <trmsw@yahoo.co.uk>
a712a8c3 60Joakim Verona <joakim@verona.se>
256c9c3a 61Dan Waber <dwaber@logolalia.com>
856dd475
KL
62and many others.
63
64Richard Stallman was kind enough to review an earlier version of my
65patches.
66
67
422f68e0
KL
68MAILING LISTS
69-------------
70
71The multi-tty mailing list (discussion & bug reports):
72
73 Address: multi-tty@lists.fnord.hu
74 Signup: http://lists.fnord.hu/mailman/listinfo/multi-tty
75 Archive: http://news.gmane.org/gmane.emacs.multi-tty/
76
77Commit notifications (read-only):
78
79 Address: multi-tty-commits@lists.fnord.hu
80 Signup: http://lists.fnord.hu/mailman/listinfo/multi-tty-commits
81
82
83STATUS
84------
85
86The branch is now very stable and almost full-featured. All of the
87major problems have been fixed, only a few minor issues remain. (It
88still needs to be ported to Windows/Mac/DOS, though.) Both multiple
89tty device support and simultaneous X and tty frame support works
90fine. Emacsclient has been extended to support opening new tty and X
6ed8eeff 91frames. It has been changed to open new Emacs frames by default.
422f68e0
KL
92
93The multi-tty branch has been scheduled for inclusion in the next
779d7de9 94major release of Emacs (version 23). I expect the merge into the
f35ca2fe 95development trunk to occur sometime during next year (2006), after the
422f68e0
KL
96merge of the Unicode branch.
97
90e06c2e
KL
98Tested on GNU/Linux, Solaris 8, FreeBSD and OpenBSD. Please let me
99know if you succeed or fail to use it on other platforms---I'll have a
100few tricky test cases for you.
422f68e0
KL
101
102Known problems:
103
779d7de9 104 * GTK support. If you compile your Emacs with the GTK
5f6a587f
KL
105 toolkit, some functionality of multi-tty will be lost. In
106 particular, you will not be able to work on multiple X
107 displays at once. Current releases of GTK have limitations
108 and bugs that prevent full-blown multi-display support in
109 Emacs. (GTK crashes when Emacs tries to disconnect from an
110 X server.) Use the Lucid toolkit if you want to see a
111 complete feature set.
779d7de9 112
856dd475
KL
113 * The single-kboard mode.
114
115 If your multi-tty Emacs session seems to be frozen, you
116 probably have a recursive editing session or a pending
117 minibuffer prompt (which is a kind of recursive editing) on
118 another display. To unfreeze your session, switch to that
119 display and complete the recursive edit, for example by
120 pressing C-] (`abort-recursive-edit').
121
122 I am sorry to say that currently there is no way to break
123 out of this "single-kboard mode" from a frozen display. If
124 you are unable to switch to the display that locks the
125 others (for example because it is on a remote computer),
126 then you can use emacsclient to break out of all recursive
127 editing sessions:
128
129 emacsclient -e '(top-level)'
130
131 Note that this (perhaps) unintuitive behaviour is by design.
132 Single-kboard mode is required because of an intrinsic Emacs
133 limitation that is very hard to eliminate. (This limitation
134 is related to the single-threaded nature of Emacs.)
135
136 I plan to implement better user notification and support for
137 breaking out of single-kboard mode from locked displays.
138
139 * Mac, Windows and DOS support is broken, doesn't even
140 compile. Multiple display support will probably not provide
141 new Emacs features on these systems, but the multi-tty
142 branch changed a few low-level interfaces, and the
143 system-dependent source files need to be adapted
144 accordingly. The changes are mostly trivial, so almost
145 anyone can help, if only by compiling the branch and
f35ca2fe 146 reporting the compiler errors.
856dd475 147
422f68e0 148
422f68e0
KL
149HOW TO GET THE BRANCH
150---------------------
151
f35ca2fe 152The branch uses Bazaar 1 (http://bazaar.canonical.com) for version control.
28d440ab 153
6548cf00 154Retrieving the latest version of the branch:
4f0359de 155
f35ca2fe
KL
156 baz register-archive -f http://aszt.inf.elte.hu/~lorentey/mirror/arch/2004
157 baz get lorentey@elte.hu--2004/emacs--multi-tty <directory>
be0f4123 158
f35ca2fe
KL
159This incantation uses an archive mirror that is hosted on a
160high-bandwidth site. Please note that on average there is a two-hour
161delay for commits to arrive on this mirror. My primary mirror is on the
162low-bandwidth http://lorentey.hu/ site:
779d7de9 163
f35ca2fe
KL
164 baz register-archive -f http://lorentey.hu/arch/2004/
165 baz get lorentey@elte.hu--2004/emacs--multi-tty <directory>
779d7de9 166
f35ca2fe
KL
167This is "instantly" updated, but very slow from outside Hungary.
168(By "instantly" I mean as soon as I connect the notebook I work on to
169a network. It could take days.)
779d7de9
KL
170
171The Arch supermirror provides mirroring services for all public Arch
172repositories. We have a mirror there, too, if you prefer.
be0f4123 173
f35ca2fe
KL
174 baz register-archive -f http://mirrors.sourcecontrol.net/lorentey%40elte.hu--2004
175 baz get lorentey@elte.hu--2004/emacs--multi-tty <directory>
4f0359de 176
44d7460c
KL
177My GPG key id is 0FB27A3F; it is available from
178hkp://wwwkeys.eu.pgp.net/, or from my homepage at
422f68e0 179http://lorentey.hu/rolam/gpg.html)
7b00d185 180
856dd475
KL
181Don't worry if the above checkout takes a few minutes to complete;
182once you have a source tree, updating it to the latest revision will
183be _much_ faster. Use the following command for the update:
6ad9aaa9 184
f35ca2fe 185 baz replay
6ad9aaa9 186
f35ca2fe
KL
187You can find more information about Bazaar on
188http://bazaar.canonical.com/. It's a distributed source control
189system that is somewhat less broken than competing projects.
6ad9aaa9 190
f35ca2fe 191If you don't have Bazaar, the branch has a homepage from which you can
7b00d185 192download conventional patches against Emacs CVS HEAD:
4f0359de 193
be0f4123 194 http://lorentey.hu/project/emacs.html
28d440ab 195
f35ca2fe
KL
196I suggest you use Bazaar whenever feasible.
197
198
779d7de9
KL
199DEBIAN PACKAGES
200---------------
201
202If you run Debian, or a distribution based on Debian, you are welcome
203to use our binary packages; put these lines in your /etc/apt/sources.list:
204
205 # Multi-tty Emacs
d6805803
KL
206 deb http://aszt.inf.elte.hu/~lorentey/mirror/apt unstable multi-tty
207 deb-src http://aszt.inf.elte.hu/~lorentey/mirror/apt unstable multi-tty
779d7de9
KL
208
209Note that these packages are intended solely to provide an easy way to
210test the new multi-tty features. They are not to be taken as Emacs
211releases, and it's a mistake to expect robust operation or any kind of
212timely support for them. Do not install them, unless you'd like to
213have your editor crash on you.
214
28d440ab 215
90e06c2e
KL
216COMPILATION
217-----------
0c72d684 218
d03a8fe4 219The multi-tty branch is compiled the same way as Emacs itself:
bc279d67 220
90e06c2e
KL
221 make maintainer-clean # (If you have compiled Emacs before)
222
d6805803 223 ./configure --without-gtk <your favourite options>
bc279d67 224 make bootstrap
d03a8fe4
KL
225 make install
226
90e06c2e
KL
227If you have strange compilation errors, they may be caused by old
228*.elc files that are left over from an earlier bootstrap. The `make
229maintainer-clean' target deletes them, so it is a good idea to run
230that before reporting a bug. (Emacs requires a clean recompilation
231after certain kinds of source code changes.)
d03a8fe4 232
90e06c2e
KL
233TESTING
234-------
235
236To test the multi-tty branch, start up the Emacs server with the
d03a8fe4
KL
237following commands:
238
239 emacs
7b00d185 240 M-x server-start
bc279d67 241
7b00d185
KL
242and then (from a shell prompt on another terminal) start emacsclient
243with
d03a8fe4
KL
244 emacsclient -t /optional/file/names... (for a tty frame)
245 emacsclient /optional/file/names... (for an X frame)
28d440ab 246
d03a8fe4 247(Make sure both emacs and emacsclient are multi-tty versions.)
04c3243c 248You'll hopefully have two fully working, independent frames on
7b00d185 249separate terminals. The new frame is closed automatically when you
2a0c7b06
KL
250finish editing the specified files (C-x #), but delete-frame (C-x 5 0)
251also works. Of course, you can create frames on more than two tty
252devices.
52c2ee2a 253
f35ca2fe 254Creating new frames on the same tty with C-x 5 2 (make-frame-command)
6ed8eeff
KL
255works, and behaves the same way as in previous Emacs versions. If you
256exit emacs, all terminals should be restored to their previous states.
daf01701 257
856dd475
KL
258This is work in progress, and probably full of bugs. It is a good
259idea to run emacs from gdb, so that you'll have a live instance to
260debug if something goes wrong. Please send me your bug reports on our
261mailing list: multi-tty@lists.fnord.hu
04c3243c 262
422f68e0
KL
263TIPS & TRICKS
264-------------
265
bacb6689
KL
266I think the best way to use the new Emacs is to have it running inside
267a disconnected GNU screen session, and always use emacsclient for
422f68e0
KL
268normal work. One advantage of this is that not a single keystroke of
269your work will be lost if the display device that you are using
270crashes, or the network connection times out, or whatever. (I had an
271extremely unstable X server for some time while I was developing these
272patches, and running Emacs this way has saved me a number of M-x
273recover-session invocations.)
274
97c57fb2
KL
275I use the following two bash scripts to handle my Emacs sessions:
276
277-------------------------------------------------------connect-emacs--
278#!/bin/bash
279# Usage: connect-emacs <name> <args>...
280#
281# Connects to the Emacs instance called NAME. Starts up the instance
282# if it is not already running. The rest of the arguments are passed
283# to emacsclient.
284
285name="$1"
286shift
287
288if [ -z "$name" ]; then
289 echo "Usage: connect_emacs <name> <args>..." >&2
290 exit 1
291fi
292preload-emacs "$name" wait
293/usr/bin/emacsclient.emacs-multi-tty -s "$name" "$@"
294----------------------------------------------------------------------
295
296-------------------------------------------------------preload-emacs--
297#!/bin/bash
298# Usage: preload-emacs <name> [<waitp>]
299#
300# Preloads the Emacs instance called NAME in a detached screen
301# session. Does nothing if the instance is already running. If WAITP
302# is non-empty, the function waits until the server starts up and
303# creates its socket; otherwise it returns immediately.
304
305name="$1"
306waitp="$2"
307screendir="/var/run/screen/S-$USER"
308serverdir="/tmp/emacs$UID"
309emacs=/usr/bin/emacs-multi-tty # Or wherever you installed your multi-tty Emacs
310
311if [ -z "$name" ]; then
312 echo "Usage: preload_emacs <name> [<waitp>]" >&2
313 exit 1
314fi
315
316if [ ! -e "$screendir"/*."$name" ]; then
317 if [ -e "$serverdir/$name" ]; then
318 # Delete leftover socket (for the wait option)
319 rm "$serverdir/$name"
320 fi
321 screen -dmS "$name" "$emacs" -nw --eval "(setq server-name \"$name\")" -f server-start
322fi
323if [ ! -z "$waitp" ]; then
324 while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done
325fi
326----------------------------------------------------------------------
327
328I have the following in my profile to have two instances automatically
329preloaded for editing and email:
330
331 preload-emacs editor
332 preload-emacs gnus
333
334It is useful to set up short aliases for connect-emacs. I use the
335following:
336
337 alias edit="connect-emacs editor"
338 alias e=edit
339 alias et="connect-emacs editor -t"
340 alias gnus="connect-emacs gnus"
422f68e0 341
28d440ab 342
2a42d440
KL
343CHANGELOG
344---------
345
346See arch logs.
347
348
28d440ab
KL
349NEWS
350----
351
2a42d440 352For the NEWS file: (Needs much, much work)
28d440ab 353
6ed8eeff
KL
354** Support for multiple terminal devices and simultaneous graphical
355 and tty frames has been added. You can test for the presence of
356 this feature in your Lisp code by testing for the `multi-tty'
357 feature.
358
359*** The `window-system' variable has been made frame-local. The new
360 `initial-window-system' variable contains the `window-system'
361 value for the first frame.
6548cf00 362
2246281f
KL
363*** You can specify a terminal device (`tty' parameter) and a terminal
364 type (`tty-type' parameter) to `make-terminal-frame'.
6548cf00 365
6ed8eeff
KL
366*** The new function `make-frame-on-tty' allows you to create a new
367 frame on another tty device interactively.
368
369*** The function `make-frame-on-display' now works during a tty
370 session, and `make-frame-on-tty' works during a graphical session.
28d440ab 371
2246281f 372*** Emacsclient has been extended to support opening a new terminal
aaaf7fe1
KL
373 frame. Its behaviour has been changed to open a new Emacs frame by
374 default. Use the -c option to get the old behavior of opening
375 files in the currently selected Emacs frame.
e5299d8d 376
6ed8eeff
KL
377*** C-z now invokes `suspend-frame', C-x C-c now invokes
378 `save-buffers-kill-terminal'.
2246281f 379
2a42d440 380*** New functions: frame-tty-name, frame-tty-type, delete-tty,
6ed8eeff
KL
381 suspend-tty, resume-tty, terminal-id, terminal-parameters,
382 terminal-parameter, set-terminal-parameter,
383 modify-terminal-parameters, environment, let-environment
2246281f 384
6ed8eeff 385*** New variables: local-key-translation-map, local-function-key-map
4400e764 386
6ed8eeff
KL
387*** The `keyboard-translate-table' variable and the terminal and
388 keyboard coding systems have been made terminal-local.
2246281f 389
6ed8eeff
KL
390*** In addition to the global key-translation-map and
391 function-key-map, Emacs has terminal-local
392 local-key-translation-map and local-function-key-map variables,
393 and uses them instead of the global keymaps to set up translations
394 and function key sequences relevant to a specific terminal device.
819b8f00 395
2a42d440 396*** talk.el has been extended for multiple tty support.
28d440ab 397
90e06c2e
KL
398* * *
399
400(The rest of this file consists of my development notes and as such it
401is probably not very interesting for anyone else.)
402
7b00d185
KL
403THINGS TO DO
404------------
4edd8a5c 405
6213d5b3 406** emacsclient -t on the console does not work after su:
89121f95 407
6213d5b3 408 # su lorentey
89121f95
KL
409 $ emacsclient -t
410 *ERROR*: Could not open file: /dev/tty1
411
412 The tty can be opened as /dev/tty by emacsclient, but not by Emacs.
413 This seems to be a serious problem. Currently my only idea is to
414 bring back the ugly pty proxy hack from the initial versions of
415 multi-tty. Suggestions would be appreciated.
416
6bbba5a6
KL
417** Understand how `quit_throw_to_read_char' works, and fix any bugs
418 that come to light.
419
6bbba5a6
KL
420** See if getcjmp can be eliminated somehow. Why does Emacs allow
421 asynchronous input processing while it's reading input anyway?
422
526039df
KL
423** `delete-frame' events are handled by `special-event-map'
424 immediately when read by `read_char'. This is fine but it prevents
425 higher-level keymaps from binding that event to get notified of the
426 deleted frame.
427
428 Sometimes it would be useful for Lisp code to be notified of frame
429 deletions after they have happened, usually because they want to
430 clean up after the deleted frame. Not all frame-local states can
431 be stored as a frame parameter. For example,
432 `display-splash-screen' uses `recursive-edit' with a special keymap
433 override to create its buffer---and it leads to all kinds of
434 nastiness if Emacs stays in this recursive edit mode after the
435 frame containing the splash screen is deleted. Basically, the
436 splash-screen implementation wants to throw out of the recursive
437 edit when the frame is deleted; however, it is not legal to throw
438 from `delete-frame-functions' because `delete-frame' must not fail.
439 (Introducing `delete-frame-after-functions' would not help either
440 because `delete-frame' may not fail at that time either.)
441
442 Currently `fancy-splash-screens' installs a
443 `delete-frame-functions' hook that sets up a timer to exit the
444 recursive edit. This is an adequate solution, but it would perhaps
445 be better to have something like a `frame-deleted' event that could
446 be bound in the normal way.
447
f105f403
KL
448** Trouble: `setenv' doesn't actually set environment variables in the
449 Emacs process. This defeats the purpose of the elaborate
450 `server-with-environment' magic around the `tgetent' call in
451 `init_tty'. D'oh.
ed8dad6b
KL
452
453** (Possibly) create hooks in struct device for creating frames on a
454 specific terminal, and eliminate the hackish terminal-related frame
455 parameters (display, tty, tty-type).
456
457 make_terminal_frame
458 create_tty_output
da8e8fc1
KL
459
460** Decide whether to keep the C implementation of terminal parameters,
461 or revert to the previous, purely Lisp code. It turned out that
462 local environments do not need terminal parameters after all.
ed8dad6b
KL
463
464** Move Fsend_string_to_terminal to term.c, and declare get_named_tty
465 as static, removing it from dispextern.h.
466 Move fatal to emacs.c and declare it somewhere.
467
f35ca2fe
KL
468** Search for `suspend-emacs' references and replace them with
469 `suspend-frame', if necessary. Ditto for `save-buffers-kill-emacs'
470 vs. `save-buffers-kill-display'.
471
bedeffcf
KL
472** Emacs crashes when a tty frame is resized so that there is no space
473 for all its windows. (Tom Schutzer-Weissmann)
474
256c9c3a
KL
475** Report GTK multi-display problems to GTK maintainers. For extra
476 credit, fix them.
6bac1616 477
5f6a587f
KL
478 Currently you can not connect to new X displays when you compile
479 Emacs with GTK support. If you want to play around with GTK
480 multidisplay (and don't mind core dumps), you can edit src/config.h
481 and define HAVE_GTK_MULTIDISPLAY there by hand.
b3e6f69c 482
5f3c1a63
KL
483 http://bugzilla.gnome.org/show_bug.cgi?id=85715
484
b3e6f69c
KL
485 Update: Han reports that GTK+ version 2.8.9 almost gets display
486 disconnects right. GTK will probably be fully fixed by the time
487 multi-tty gets into the trunk.
d6805803 488
5f3c1a63
KL
489 Update: I am still having problems with GTK+ 2.8.10. I have the
490 impression that the various multidisplay fixes will only get
491 released in GTK+ 2.10.
492
f369f10b
KL
493** Audit `face-valid-attribute-values' usage in customize and
494 elsewhere. Its return value depends on the current window system.
495 Replace static initializers using it with runtime functions. For
496 example, custom's buttons are broken on non-initial device types.
497
30a2fded
KL
498** Possibly turn off the double C-g feature when there is an X frame.
499 C.f. (emacs)Emergency Escape.
500
6bac1616 501** frames-on-display-list should also accept frames.
f0caabd9 502
5b65d888
KL
503** Consider the `tty-type' frame parameter and the `display-tty-type'
504 function. They serve the exact same purpose. I think it may be
505 a good idea to eliminate one of them, preferably `tty-type'.
506
4400e764
KL
507** The handling of lisp/term/*.el, and frame creation in general, is a
508 big, big mess. How come the terminal-specific file is loaded by
509 tty-create-frame-with-faces? I don't think it is necessary to load
510 these files for each frame; once per terminal should be enough.
6bac1616
KL
511 Update: lisp/term/*.el is not loaded repeatedly anymore, but
512 faces.el still needs to be cleaned up.
4400e764
KL
513
514** Fix frame-set-background-mode in this branch. It was recently
515 changed in CVS, and frame.el in multi-tty has not yet been adapted
516 for the changes. (It needs to look at
6bac1616 517 default-frame-background-mode.) (Update: maybe it is fixed now;
30663b47
KL
518 needs testing.) (Note that the byte compiler has this to say about
519 term/rxvt.el:)
520
521 term/rxvt.el:309:17:Warning: assignment to free variable
522 `default-frame-background-mode'
4400e764
KL
523
524** I think `(set-)terminal-local-value' and the terminal parameter
525 mechanism should be integrated into a single framework.
526
ed8dad6b
KL
527 (Update: `(set-)terminal-local-value' is now eliminated, but the
528 terminal-local variables should still be accessible as terminal
529 parameters. This also applies to `display-name' and similar
530 functions.)
531
4400e764
KL
532** Add the following hooks: after-delete-frame-hook (for server.el,
533 instead of delete-frame-functions),
534 after-delete-terminal-functions, after-create-terminal-functions.
535
1fb8c4ad
KL
536** BULK RENAME: The `display-' prefix of new Lisp-level functions
537 conflicts with stuff like `display-time-mode'. Use `device-'
7d6d7d1a
KL
538 or `terminal-' instead. I think I prefer `terminal-'.
539
3e6f836c
KL
540 It turns out that most of the offending Lisp functions were defined
541 in the trunk. Therefore, compatibility aliases should be defined
542 for the following names:
543
544 display-color-cells terminal-color-cells
545 display-color-p terminal-color-p
546 display-graphic-p terminal-graphic-p
547 display-grayscale-p terminal-grayscale-p
548 display-images-p terminal-images-p
549 display-mm-height terminal-mm-height
550 display-mm-width terminal-mm-width
551 display-mouse-p terminal-mouse-p
552 display-multi-font-p terminal-multi-font-p
553 display-multi-frame-p terminal-multi-frame-p
554 display-pixel-height terminal-pixel-height
555 display-pixel-width terminal-pixel-width
556 display-pixels-per-inch terminal-pixels-per-inch
557 display-planes terminal-planes
558 display-popup-menus-p terminal-popup-menus-p
559 display-save-under terminal-save-under
560 display-screens terminal-screens
561 display-supports-face-attributes-p terminal-supports-face-attributes-p
562 display-visual-class terminal-visual-class
563 framep-on-display framep-on-terminal
564 frames-on-display-list frames-on-terminal-list
565
566 The following functions were introduced in the multi-tty branch, and
6ed8eeff 567 were renamed without aliases:
3e6f836c 568
6ed8eeff
KL
569 delete-display delete-terminal
570 display-controlling-tty-p controlling-tty-p
3e6f836c
KL
571 display-list terminal-list
572 display-live-p terminal-live-p
573 display-name terminal-name
6ed8eeff
KL
574 display-tty-type tty-type
575 frame-display frame-terminal
576 selected-display selected-terminal
3e6f836c 577
856dd475
KL
578** The single-keyboard mode of MULTI_KBOARD is extremely confusing
579 sometimes; Emacs does not respond to stimuli from other keyboards.
580 At least a beep or a message would be important, if the single-mode
581 is still required to prevent interference. (Reported by Dan
582 Nicolaescu.)
583
584 Update: selecting a region with the mouse enables single_kboard
585 under X. This is very confusing.
586
68bba4e4
KL
587 Update: After discussions with Richard Stallman, this will be
588 resolved by having locked displays warn the user to wait, and
589 introducing a complex protocol to remotely bail out of
590 single-kboard mode by pressing C-g.
856dd475
KL
591
592 Update: Warning the user is not trivial to implement, as Emacs has
68bba4e4
KL
593 only one echo area, shared by all frames. Ideally the warning
594 should not be displayed on the display that is locking the others.
595 Perhaps the high probability of user confusion caused by
596 single_kboard mode deserves a special case in the display code.
597 Alternatively, it might be good enough to signal single_kboard mode
598 by changing the modelines or some other frame-local display element
599 on the locked out displays.
856dd475 600
b3e6f69c
KL
601 Update: In fact struct kboard does have an echo_string slot.
602
d51abf22
KL
603** The session management module is prone to crashes when the X
604 connection is closed and then later I try to connect to a new X
605 session:
606
607 #0 0xb7ebc806 in SmcGetIceConnection () from /usr/X11R6/lib/libSM.so.6
608 #1 0x080e6641 in x_session_check_input (bufp=0xbf86c9c0) at xsmfns.c:144
609 #2 0x080d3bbc in XTread_socket (device=0xa722ff8, expected=1, hold_quit=0xbf86ca90) at xterm.c:7037
610 #3 0x080fa404 in read_avail_input (expected=1) at keyboard.c:6696
611 #4 0x080fa4ca in handle_async_input () at keyboard.c:6900
612 #5 0x080d51fa in x_term_init (display_name=162628899, xrm_option=0x0, resource_name=0x857068c "emacs") at xterm.c:10622
613 #6 0x080d920e in x_display_info_for_name (name=162628899) at xfns.c:3975
614 #7 0x080d92f9 in check_x_display_info (object=1) at xfns.c:274
615 #8 0x080d97b8 in Fx_create_frame (parms=151221485) at xfns.c:3016
616 #9 0x0815bf72 in Ffuncall (nargs=2, args=0xbf86ceec) at eval.c:2851
617
618 I installed a workaround to prevent this. The X session manager is
619 only contacted when the very first display in the Emacs session is
620 an X display. Also, x_delete_display() on this display aborts
621 session management, and XTread_socket only calls
622 x_session_check_input when it is called for the display that the
623 session was opened on. While this does not really fix the bug, it
624 makes it much less frequent, because session manager support will
625 not normally be enabled when Emacs can survive the shutdown of the
626 X server.
627
628 See if xsmfns.c should be updated.
629
b6660415
KL
630** Hunt down display-related functions in frame.el and extend them all
631 to accept display ids.
632
856dd475
KL
633** rif->flush_display_optional (NULL) calls should be replaced by a
634 new global function.
635
97c57fb2
KL
636** The set-locale-environment hack (adding the DISPLAY option) should
637 be replaced with a clean design.
68bba4e4 638
97c57fb2
KL
639** standard-display-table should be display-local.
640 standard-display-european should be display-local.
68bba4e4 641
7d6d7d1a
KL
642** With iswitchb-default-method set to 'always-frame, only frames on
643 the current display should be considered. This might involve
644 extending `get-buffer-window'.
645
97c57fb2
KL
646** Have a look at Vlocale_coding_system. Seems like it would be a
647 tedious job to localize it, although most references use it for
648 interfacing with libc and are therefore OK with the global
649 definition.
650
651 Exceptions found so far: x-select-text and
652 x-cut-buffer-or-selection-value.
68bba4e4 653
6ea444cf
KL
654** Have a look at fatal_error_hook.
655
97b977db
KL
656** Have a look at set_frame_matrix_frame.
657
7d1a6b33
KL
658** Check if we got term-setup-hook right.
659
9d3d44ba
KL
660** I think tip_frame should be display-local.
661
662** Check display reference count handling in x_create_tip_frame.
663
54021676
KL
664** make-frame does not correctly handle extra parameters in its
665 argument:
666
667 (frame-parameter (make-frame (list (cons 'foobar 42))) 'foobar)
668 => nil
669
670 (This is likely an error in the CVS trunk.)
671
01d81f75
KL
672** Dan Nicolaescu suggests that -nw should be added as an alias for -t
673 in emacsclient. Good idea. (Alas, implementing this is not
674 trivial, getopt_long does not seem to support two-letter ``short''
d6805803 675 options. Patches are welcome.)
01d81f75
KL
676
677** Mark Plaksin suggests that emacsclient should accept the same
678 X-related command-line arguments as Emacs. Most of the X-related
679 argument-handling is done in Lisp, so this should be quite easy to
680 implement.
d448e982 681
cd5355f9
KL
682** Gergely Nagy suggests that C-x # should only kill the current
683 frame, not any other emacsclient frame that may have the same file
684 opened for editing. I think I agree with him.
685
0b0d3e0b
KL
686** Very strange bug: visible-bell does not work on secondary
687 terminals in xterm and konsole. The screen does flicker a bit,
688 but it's so quick it isn't noticable.
689
b3e6f69c
KL
690 (Update: This is probably some problem with padding or whatnot on
691 the secondary terminals.)
692
428a555e 693** Move baud_rate to struct display.
7b00d185 694
7b00d185
KL
695** Implement support for starting an interactive Emacs session without
696 an initial frame. (The user would connect to it and open frames
f70dd009 697 later, with emacsclient.)
7b00d185 698
2cd1371d
KL
699** Fix Mac support (I can't do this entirely myself). Note that the
700 current state of Mac-specific source files in the multi-tty tree
701 are not useful; before starting work on Mac support, revert to
702 pristine, pre-multi-tty versions.
7b00d185 703
2cd1371d
KL
704** Fix W32 support (I can't do this entirely myself). Note that the
705 current state of W32-specific source files in the multi-tty tree
706 are not useful; before starting work on W32 support, revert to
707 pristine, pre-multi-tty versions.
7b00d185 708
2cd1371d
KL
709** Fix DOS support (I can't do this entirely myself). Note that the
710 current state of DOS-specific source files in the multi-tty tree
711 are not useful; before starting work on DOS support, revert to
712 pristine, pre-multi-tty versions.
7b00d185
KL
713
714** Do a grep on XXX and ?? for more issues.
715
2e478293
KL
716** flow-ctrl.el must be updated.
717
7d6d7d1a
KL
718** Fix stuff_char for multi-tty. Doesn't seem to be of high priority.
719
6548cf00
KL
720DIARY OF CHANGES
721----------------
722
723(ex-TODO items with explanations.)
28d440ab 724
114a8b8c 725-- Introduce a new struct for terminal devices.
28d440ab 726
daf01701 727 (Done, see struct tty_output. The list of members is not yet
28d440ab
KL
728 complete.)
729
28d440ab
KL
730-- Change the bootstrap procedure to initialize tty_list.
731
732 (Done, but needs review.)
733
28d440ab
KL
734-- Change make-terminal-frame to support specifying another tty.
735
736 (Done, new frame parameters: `tty' and `tty-type'.)
737
9628b887
KL
738-- Implement support for reading from multiple terminals.
739
740 (Done, read_avail_input tries to read from each terminal, until one
28d7d09f 741 succeeds. MULTI_KBOARD is not used. Secondary terminals don't send
6548cf00 742 SIGIO!)
9628b887 743
819b8f00
KL
744 (Update: They do, now.)
745
daf01701
KL
746 (Update2: After enabling X, they don't.)
747
9628b887 748-- other-frame should cycle through the frames on the `current'
114a8b8c 749 terminal only.
9628b887 750
6548cf00 751 (Done, by trivially modifiying next_frame and prev_frame.)
9628b887
KL
752
753-- Support different terminal sizes.
114a8b8c 754
9628b887
KL
755 (Done, no problem.)
756
757-- Make sure terminal resizes are handled gracefully. (Could be
758 problematic.)
759
6548cf00
KL
760 (Done. We don't get automatic SIGWINCH for additional ttys,
761 though.)
9628b887
KL
762
763-- Extend emacsclient to automatically open a new tty when it connects
764 to Emacs.
114a8b8c 765
9628b887
KL
766 (Done. It's an ugly hack, needs more work.)
767
52c2ee2a
KL
768-- Redisplay must refresh the topmost frame on *all* terminals, not
769 just the initial terminal.
114a8b8c 770
52c2ee2a 771 (Done, but introduced an ugly redisplay problems. Ugh.)
9628b887 772
6548cf00
KL
773-- Fix redisplay problems.
774
52c2ee2a
KL
775 (Done; it turned out that the entire Wcm structure must be moved
776 inside tty_output. Why didn't I catch this earlier?)
6548cf00
KL
777
778-- Provide a way for emacsclient to tell Emacs that the tty has been
779 resized.
780
781 (Done, simply forward the SIGWINCH signal.)
782
783-- Each keypress should automatically select the frame corresponding
784 to the terminal that it was coming from. This means that Emacs
785 must know from which terminal the last keyboard event came from.
6548cf00 786
52c2ee2a
KL
787 (Done, it was quite simple, the input event system already
788 supported multiple frames.)
6548cf00
KL
789
790-- Fix SIGIO issue with secondary terminals.
791
792 (Done, emacsclient signals Emacs after writing to the proxy pseudo
52c2ee2a
KL
793 terminal. Note that this means that multi-tty does not work with
794 raw ttys!)
28d440ab 795
0a125897
KL
796 (Update: This is bullshit. There is a read_input_waiting function,
797 extend that somehow.)
798
819b8f00
KL
799 (Update of update: The first update was not right either, extending
800 read_input_waiting was not necessary. Secondary ttys do seem to
801 send signals on input.)
802
daf01701
KL
803 (Update^3: Not any more.)
804
fca177d4
KL
805-- Make make-terminal-frame look up the `tty' and `tty-type' frame
806 parameters from the currently selected terminal before the global
807 default.
808
809 (Done.)
810
811-- Put all cached terminal escape sequences into struct tty_output.
812 Currently, they are still stored in global variables, so we don't
813 really support multiple terminal types.
814
52c2ee2a 815 (Done. It was not fun.)
fca177d4
KL
816
817-- Implement sane error handling after initialization. (Currently
6548cf00
KL
818 emacs exits if you specify a bad terminal type.) The helpful error
819 messages must still be provided when Emacs starts.
820
fca177d4
KL
821 (Done.)
822
823-- Implement terminal deletion, i.e., deleting local frames, closing
824 the tty device and restoring its previous state without exiting
825 Emacs.
9628b887 826
fca177d4
KL
827 (Done, but at the moment only called when an error happens during
828 initialization. There is a memory corruption error around this
daf01701 829 somewhere.) (Update: now it is fully enabled.)
fca177d4 830
8303ba32
KL
831-- Implement automatic deletion of terminals when the last frame on
832 that terminal is closed.
833
834 (Done.)
835
0a125897
KL
836-- Restore tty screen after closing the terminal.
837
838 (Done, we do the same as Emacs 21.2 for all terminals.)
839
840-- 'TERM=dumb src/emacs' does not restore the terminal state.
114a8b8c 841
0a125897 842 (Done.)
fca177d4 843
b2af72d2
KL
844-- C-g should work on secondary terminals.
845
846 (Done, but the binding is not configurable.)
847
848-- Deal with SIGHUP in Emacs and in emacsclient. (After this, the
849 server-frames may be removed from server.el.)
850
851 (Done, nothing to do. It seems that Emacs does not receive SIGHUP
daf01701 852 from secondary ttys, which is actually a good thing.) (Update: I
7b00d185 853 think it would be a bad idea to remove server-frames.)
b2af72d2 854
daf01701 855-- Change emacsclient/server.el to support the -t argument better,
b2af72d2
KL
856 i.e. automatically close the socket when the frame is closed.
857
858 (Seems to be working OK.)
859
16c290d8 860-- Fix mysterious memory corruption error with tty deletion. To
fca177d4
KL
861 trigger it, try the following shell command:
862
863 while true; do TERM=no-such-terminal-definition emacsclient -h; done
864
865 Emacs usually dumps core after a few dozen iterations. (The bug
3224dac1 866 seems to be related to the xfreeing or bzeroing of
9d9f1812
KL
867 tty_output.Wcm. Maybe there are outside references to struct Wcm?
868 Why were these vars collected into a struct before multi-tty
869 support?)
fca177d4 870
16c290d8
KL
871 (Done. Whew. It turned out that the problem had nothing to do
872 with hypothetical external references to Wcm, or any other
873 tty_output component; it was simply that delete_tty closed the
874 filehandles of secondary ttys twice, resulting in fclose doubly
3224dac1 875 freeing memory. Utterly trivial matter. I love the C's memory
16c290d8
KL
876 management, it puts hair on your chest.)
877
819b8f00 878-- Support raw secondary terminals. (Note that SIGIO works only on
3224dac1 879 the controlling terminal.) Hint: extend read_input_waiting for
819b8f00 880 multiple ttys and hopefully this will be fixed.
fca177d4 881
819b8f00
KL
882 (Done, it seems to have been working already for some time. It
883 seems F_SETOWN does work, after all. Not sure what made it fail
884 earlier, but it seems to be fixed (there were several changes
885 around request_sigio, maybe one of them did it).
3224dac1 886 read_input_waiting is only used in sys_select, don't change
daf01701 887 it.) (Update: After adding X support, it's broken again.)
d3c554a0 888 (Update^2: No it isn't.) :-)
c1c63edb 889
819b8f00 890-- Find out why does Emacs abort when it wants to close its
0a125897 891 controlling tty. Hint: chan_process[] array. Hey, maybe
16c290d8
KL
892 noninterrupt-IO would work, too? Update: no, there is no process
893 for stdin/out.
c33d2d42 894
819b8f00
KL
895 (Done. Added add/delete_keyboard_wait_descriptor to
896 term_init/delete_tty. The hint was right, in a way.)
6548cf00 897
819b8f00 898-- Issue with SIGIO: it needs to be disabled during redisplay. See if
3224dac1 899 fcntl kernel behaviour could be emulated by emacsclient.
0a125897 900
819b8f00 901 (Done. Simply disabled the SIGIO emulation hack in emacsclient.)
d3c554a0 902 (Update: it was added back.) (Update^2: and removed again.)
22de1e79 903
819b8f00 904-- server.el: There are issues with saving files in buffers of closed
16c290d8
KL
905 clients. Try editing a file with emacsclient -f, and (without
906 saving it) do a delete-frame. The frame is closed without
907 question, and a surprising confirmation prompt appears in another
908 frame.
909
819b8f00
KL
910 (Done. delete-frame now asks for confirmation if it still has
911 pending buffers, and modified buffers don't seem to be deleted.)
912
913-- emacsclient.el, server.el: Handle eval or file open errors when
daf01701 914 doing -t.
16c290d8 915
819b8f00 916 (Done.)
22de1e79 917
819b8f00
KL
918-- Make parts of struct tty_output accessible from Lisp. The device
919 name and the type is sufficient.
22de1e79 920
819b8f00
KL
921 (Done, see frame-tty-name and frame-tty-type.)
922
923-- Export delete_tty to the Lisp environment, for emacsclient.
22de1e79 924
819b8f00
KL
925 (Done, see delete-tty.)
926
daf01701
KL
927-- Get rid of the accessor macros in termchar.h, or define macros for
928 all members.
929
930 (Done.)
931
932-- Move device-specific parameters (like costs) commonly used by
933 device backends to a common, device-dependent structure.
934
935 (Done. See struct display_method in termhooks.h.)
936
937-- Fix X support.
938
939 (Done. Well, it seems to be working.)
940
941-- Allow simultaneous X and tty frames. (Handling input could be
942 tricky. Or maybe not.)
943
944 (Done. Allowed, that is. It is currently extremely unstable, to
945 the point of being unusable. The rif variable causes constant
946 core dumps. Handling input is indeed tricky.)
819b8f00 947
7b00d185 948-- Rewrite multi-tty input in terms of MULTI_KBOARD.
28d440ab 949
7b00d185
KL
950 (Done. In fact, there was no need to rewrite anything, I just
951 added a kboard member to tty_display_info, and initialized the
952 frame's kboard from there.)
819b8f00 953
fa971ac3
KL
954-- Fix rif issue with X-tty combo sessions. IMHO the best thing to do
955 is to get rid of that global variable (and use the value value in
956 display_method, which is guaranteed to be correct).
957
958 (Done, did exactly that. Core dumps during combo sessions became
959 much rarer. In fact, I have not yet met a single one.)
960
17086732
KL
961-- Add multi-tty support to talk.el.
962
963 (Done.)
964
428a555e
KL
965-- Clean up the source of emacsclient. It is a mess.
966
967 (Done, eliminated stupid proxy-pty kludge.)
968
969-- Fix faces on tty frames during X-tty combo sessions. There is an
970 init_frame_faces call in init_sys_modes, see if there is a problem
971 with it.
972
973 (Done, there was a stupid mistake in
974 Ftty_supports_face_attributes_p. Colors are broken, though.)
975
976-- C-x 5 2, C-x 5 o, C-x 5 0 on an emacsclient frame unexpectedly
977 exits emacsclient. This is a result of trying to be clever with
978 delete-frame-functions.
979
980 (Fixed, added delete-tty-after-functions, and changed server.el to
981 use it.)
982
983-- Something with (maybe) multi-keyboard support broke function keys
984 and arrows on ttys during X+tty combo sessions. Debug this.
985
986 (I can't reproduce it, maybe the terminal type was wrong.)
987
988-- Fix input from raw ttys (again).
989
990 (Now it seems to work all right.)
991
992-- During an X-tty combo session, a (message "Hello") from a tty frame
993 goes to the X frame. Fix this.
994
995 (Done. There was a safeguard against writing to the initial
996 terminal frame during bootstrap which prevented echo_area_display
997 from working correctly on a tty frame during a combo session.)
998
114a8b8c 999-- If there are no frames on its controlling terminal, Emacs should
d3c554a0 1000 exit if the user presses C-c there.
114a8b8c
KL
1001
1002 (Done, as far as possible. See the SIGTERM comment in
1003 interrupt_signal on why this seems to be impossible to solve this
1004 in general.)
1005
1006-- During an X session, Emacs seems to read from stdin. Also, Emacs
1007 fails to start without a controlling tty.
1008
1009 (Fixed by replacing the troublesome termcap display with a dummy
1010 bootstrap display during bootstrap.
1011
1012-- Do tty output through struct display, like graphical display
1013 backends.
1014
1015 (Done.)
1016
1017-- Define an output_initial value for output_method for the initial
1018 frame that is dumped with Emacs. Checking for this frame (e.g. in
1019 cmd_error_internal) is ugly.
1020
d6805803 1021 (Done, breaking interactive temacs.)
114a8b8c
KL
1022
1023-- The command `emacsclient -t -e '(delete-frame)'' fails to exit.
1024
1025 (Fixed.)
1026
4ca927b4
KL
1027-- frame-creation-function should always create a frame that is on the
1028 same display as the selected frame. Maybe frame-creation-function
1029 should simply be removed and make-frame changed to do the right
1030 thing.
1031
1032 (Done, with a nice hack. frame-creation-function is now frame-local.)
1033
1034-- Fix C-g on raw ttys.
1035
1036 (Done. I disabled the interrupt/quit keys on all secondary
1037 terminals, so Emacs sees C-g as normal input. This looks like an
1038 overkill, because emacsclient has extra code to pass SIGINT to
1039 Emacs, so C-g should remain the interrupt/quit key on emacsclient
1040 frames. See the next entry why implementing this distinction would
1041 be a bad idea.)
1042
1043-- Make sure C-g goes to the right frame with ttys. This is hard, as
1044 SIGINT doesn't have a tty parameter. :-(
1045
1046 (Done, the previous change fixes this as a pleasant side effect.)
1047
c0707982
KL
1048-- I have seen a case when Emacs with multiple ttys fell into a loop
1049 eating 100% of CPU time. Strace showed this loop:
1050
1051 getpid() = 30284
1052 kill(30284, SIGIO) = 0
1053 --- SIGIO (I/O possible) @ 0 (0) ---
1054 ioctl(6, FIONREAD, [0]) = -1 EIO (Input/output error)
1055 ioctl(5, FIONREAD, [0]) = -1 EIO (Input/output error)
1056 ioctl(0, FIONREAD, [0]) = 0
1057 sigreturn() = ? (mask now [])
1058 gettimeofday({1072842297, 747760}, NULL) = 0
1059 gettimeofday({1072842297, 747806}, NULL) = 0
1060 select(9, [0 3 5 6], NULL, NULL, {0, 0}) = 2 (in [5 6], left {0, 0})
1061 select(9, [0 3 5 6], NULL, NULL, {0, 0}) = 2 (in [5 6], left {0, 0})
1062 gettimeofday({1072842297, 748245}, NULL) = 0
1063
1064 I have seen something similar with a single X frame, but have not
1065 been able to reproduce it for debugging.
1066
1067 Update: This may have been caused by checking for nread != 0
1068 instead of nread > 0 after calling read_socket_hook in
1069 read_avail_input.
1070
1071 (Fixed. This was caused by unconditionally including stdin in
1072 input_wait_mask in init_process. The select call in
1073 wait_reading_process_input always returned immediately, indicating
1074 that there is pending input from stdin, which nobody read.
1075
1076 Note that the above strace output seems to be an unrelated but
1077 similar bug. I think that is now fixed.)
4ca927b4 1078
2246281f
KL
1079-- Exiting Emacs while there are emacsclient frames doesn't restore the
1080 ttys to their default states.
1081
1082 (This seems to be fixed by some previous change.)
1083
1084-- Allow opening an X session after -nw.
1085
1086 (Done.)
1087
d448e982
KL
1088-- Fix color handling during tty+X combo sessions. (It seems that tty
1089 sessions automatically convert the face colors to terminal colors
1090 when the face is loaded. This conversion must happen instead on
1091 the fly in write_glyphs, which might be problematic, as color
1092 approximation is currently done in lisp (term/tty-colors.el).)
1093 (Update: hm, colors seem to work fine if I start emacs with -nw and
1094 then create an X frame. Maybe it's just a small buglet somewhere.)
1095
1096 (Seems to be fixed. The problem was in startup.el, it did not
1097 initialize tty colors when the initial window system was
1098 graphical.)
2246281f 1099
2441679b
KL
1100-- emacs -nw --eval '(y-or-n-p "Foobar")' segfaults. (Reported by
1101 Romain Francoise)
1102
1103 (Fixed, there was a keyboard initialization problem.)
1104
3bbdbec9
KL
1105-- Fix interactive use of temacs. There are face-related SEGVs, most
1106 likely because of changes in realize_default_face, realize_face.
1107
1108 (Fixed.)
1109
bacb6689
KL
1110-- Don't exit Emacs when the last X connection fails during a
1111 multi-display session.
1112
1113 (Fixed.)
1114
0c72d684
KL
1115-- Dan Nicolaescu noticed that starting emacsclient on the same
1116 terminal device that is the controlling tty of the Emacs process
1117 gives unexpected results.
1118
1119 (Fixed.)
1120
4edd8a5c
KL
1121-- Istvan Marko reported that Emacs hang on ttys if it was started
1122 from a shell script.
1123
1124 (Fixed. There was a bug in the multi-tty version of
1125 narrow_foreground_group. tcsetpgrp blocks if it is called from a
1126 process that is not in the same process group as the tty.)
1127
2fc0cf2a
KL
1128-- emacsclient -t from an Emacs term buffer does not work, complains
1129 about face problems. This can even lock up Emacs (if the recursive
1130 frame sets single_kboard). Update: the face problems are caused by
1131 bugs in term.el, not in multi-tty. The lockup is caused by
d3c554a0 1132 single_kboard mode, and is not easily resolvable. The best thing to
2fc0cf2a
KL
1133 do is to simply refuse to create a tty frame of type `eterm'.
1134
1135 (Fixed, changed emacsclient to check for TERM=eterm. The face
1136 complaints seem to be caused by bugs in term.el; they are not
1137 related to multi-tty.)
1138
0b0d3e0b
KL
1139-- Find out the best way to support suspending Emacs with multiple
1140 ttys. My guess: disable it on the controlling tty, but from other
1141 ttys pass it on to emacsclient somehow. (It is (I hope) trivial to
1142 extend emacsclient to handle suspend/resume. A `kill -STOP' almost
1143 works right now.)
1144
1145 (Done. I needed to play with signal handling and the server
1146 protocol a bit to make emacsclient behave as a normal UNIX program
1147 wrt foreground/background process groups.)
1148
eb1f46c9
KL
1149-- There is a flicker during the startup of `emacs -nw'; it's as if
1150 the terminal is initialized, reset and then initialialized again.
1151 Debug this. (Hint: narrow_foreground_group is called twice during
1152 startup.)
1153
1154 (This is gone.)
1155
026ad6ba
KL
1156-- Robert Chassell has found serious copy-paste bugs with the
1157 multi-tty branch. There seem to be redisplay bugs while copying
1158 from X to a terminal frame. Copying accented characters do not
1159 work for me.
1160
1161 (Patch-124 should fix this, by changing the interprogram-*-function
1162 variables to be frame-local, as suggested by Mark Plaksin
1163 (thanks!). I think that the redisplay bugs are in fact not bugs,
1164 but delays caused by single_kboard --> perhaps MULTI_KBOARD should
1165 be removed.)
1166
2cd1371d
KL
1167-- frame-creation-function was removed, which might be a bad idea.
1168 Think up a compatible solution.
1169
1170 (It was an internal interface that may be changed when necessary.)
1171
1172-- Change Lisp code not to (getenv "TERM"); use the `tty-type' frame
1173 parameter or the frame-tty-type function instead. (M-x tags-search
1174 "TERM" helps with this.) Update: Actually, all getenv invocations
1175 should be checked for multi-tty compatibility, and an interface
1176 must be implemented to get the remote client's environment.
1177
1178 (Done. Only getenv calls in lisp/term/*.el were changed; other
1179 calls should be mostly left as they are.)
1180
1181-- Add an elaborate mechanism for display-local variables. (There are
1182 already a few of these; search for `terminal-local' in the Elisp
1183 manual.)
1184
1185 (Not needed. Display-local variables could be emulated by
1186 frame-local variables.)
026ad6ba 1187
d4d89d37
KL
1188-- Emacs assumes that all terminal frames have the same locale
1189 settings as Emacs itself. This may lead to bogus results in a
1190 multi-locale setup. (E.g., while logging in from a remote client
1191 with a different locale.)
1192 (Update after new bugreport by Friedrich Delgado Friedrichs:
1193 (at least) the structs terminal_coding and keyboard_coding in
1194 coding.c must be moved to struct display, and the Lisp interface
1195 [set-]keyboard-coding-system must be adapted for the change.)
1196
1197 (Fixed. Emacs now uses the locale settings as seen by the
1198 emacsclient process for server tty frames.)
68bba4e4 1199 (Update: Not really; Vlocale_coding_system is still global.)
b6660415
KL
1200
1201-- Make `struct display' accessible to Lisp programs. Accessor functions:
1202
1203 (displayp OBJECT): Returns t if OBJECT is a display.
1204 => Implemented as display-live-p.
1205
1206 (display-list): Returns list of currently active displays.
1207 => Implemented.
1208
1209 (selected-display): Returns the display object of the selected frame.
1210 => Not strictly necessary, but implemented anyway.
1211
1212 (frame-display FRAME): Returns the display object of FRAME.
1213 => Implemented.
1214
1215 (display-frames DISPLAY): Returns a list of frames on DISPLAY.
1216 => Already implemented, see frames-on-display-list.
1217
1218 (display-type DISPLAY): Returns the type of DISPLAY, as a
1219 symbol. (See `framep'.)
1220 => Implemented as display-live-p.
1221
1222 (display-device DISPLAY): Returns the name of the device that
1223 DISPLAY uses, as a string. (E.g: "/dev/pts/16", or
1224 ":0.0")
1225 => Implemented as display-name.
1226
1227 etc.
1228
1229 See next issue why this is necessary.
1230
1231 (Update: The consensus on emacs-devel seems to be to do this via
1232 integer identifiers. That's fine by me.)
1233
1234 (Done.)
1235
1236-- The following needs to be supported:
1237
1238 $ emacsclient -t
1239 C-z
1240 $ emacsclient -t
1241 (This fails now.)
1242
1243 The cleanest way to solve this is to allow multiple displays on the
1244 same terminal device; each new emacsclient process should create
1245 its own display. As displays are currently identified by their
1246 device names, this is not possible until struct display becomes
1247 accessible as a Lisp-level object.
1248
1249 (Done.)
1250
856dd475
KL
1251-- Miles Bader suggests that C-x C-c on an emacsclient frame should
1252 only close the frame, not exit the entire Emacs session. Update:
1253 see above for a function that does this. Maybe this should be the
1254 new default?
1255
1256 (Done. This is the new default. No complaints so far.)
1257
68bba4e4
KL
1258-- Clean up the frame-local variable system. I think it's ugly and
1259 error-prone. But maybe I just haven't yet fully understood it.
1260
1261 (Nothing to do. It doesn't seem ugly any more. It's rather clever.)
856dd475 1262
97c57fb2
KL
1263-- Support multiple character locales. A version of
1264 `set-locale-environment' needs to be written for setting up
1265 display-local settings on ttys. I think calling
1266 set-display-table-and-terminal-coding-system and
1267 set-keyboard-coding-system would be enough. The language
1268 environment itself should remain a global setting.
1269
1270 (Done, by an ugly hack.)
1271
1fb8c4ad
KL
1272-- The terminal customization files in term/*.el tend to change global
1273 parameters, which may confuse Emacs with multiple displays. Change
1274 them to tweak only frame-local settings, if possible. (They tend
1275 to call define-key to set function key sequences a lot.)
1276
1277 (Done, by making `function-key-map' terminal-local (i.e., part of
1278 struct kboard). This has probably covered all the remaining problems.)
1279
2a42d440
KL
1280-- Make `function-key-map' and `key-translation-map' terminal-local.
1281
1282 (Done.)
1283
1284-- Implement `terminal-local-value' and `set-terminal-local-value' to
1285 allow deterministic access to terminal local bindings. The
1286 encode-kb package can not set up `key-translation-map' without
1287 these. The terminal-local bindings seem to be independent of what
1288 frame is selected.
1289
1290 (Done.)
6bac1616
KL
1291
1292-- xt-mouse.el needs to be adapted for multi-tty. It currently
1293 signals an error on kill-emacs under X, which prevents the user
1294 from exiting Emacs. (Reported by Mnemonikk on freenode.)
1295
1296 (Done, I hope.)
5b65d888 1297
2a42d440 1298
ee0bcfbc
KL
1299-- Having {reset,init}_all_sys_modes in set-input-mode breaks arrow
1300 keys on non-selected terminals under screen, and sometimes on other
1301 terminal types as well. The other function keys continue to work
1302 fine. Sometimes faces on these screens become garbled.
1303
1304 This only seems to affect displays that are of the same terminfo
1305 type as the selected one. Interestingly, in screen Emacs normally
1306 reports the up arrow key as `M-o A', but after the above SNAFU, it
1307 complains about `M-[ a'. UNIX ttys are a complete mystery to me,
1308 but it seems the reset-reinitialize cycle somehow leaves the
1309 non-selected terminals in a different state than usual. I have no
1310 idea how this could happen.
1311
1312 Currently set-input-mode resets only the currently selected
1313 terminal, which seems to somehow work around the problem.
1314
1315 Update:
1316
1317 Dan Nicolaescu <dann@ics.uci.edu> writes:
1318 > Some terminals have 2 modes for cursor keys: Application Mode where
1319 > the cursor keys transmit the codes defined in the terminfo entry, and
1320 > Cursor mode. Applications have to send the smkx and rmkx terminfo
1321 > strings to switch between the 2 modes. So Emacs (and emacsclient) have
1322 > to send smkx when initializing and rmkx when quitting (or on
1323 > suspend).
1324
1325 (I think patch-370 fixed this.)
1326
256c9c3a
KL
1327-- This long-standing bug (first reported by Han Boetes) seems to come
1328 and go all the time. It is time to track it down and fix it.
1329
1330 emacs
1331 M-x server-start
1332
1333 # From another xterm:
1334 emacsclient -e '(y-or-n-p "Do you want me to crash? ")'
1335 # Notice how the answer ends up in the *scratch* buffer
1336 M-x garbage-collect
1337 SIGSEGV
1338
1339 (Fixed in patch-414 after detailed analysis by Kalle Olavi Niemitalo.)
1340
30a2fded
KL
1341-- normal-erase-is-backspace-mode in simple.el needs to be updated for
1342 multi-tty (rep. by Dan Waber). (The Delete key is broken on X
1343 because of this.)
1344
1345 (Fixed in patch-427.)
1346
2e478293
KL
1347-- I think keyboard-translate-table should be made terminal-local.
1348
1349 (Done in patch-431.)
1350
9684e4c9
KL
1351-- The semantics of terminal-local variables are confusing; it is not
1352 clear what binding is in effect in any given time. See if
1353 current_kboard (or at least the terminal-local bindings exported to
1354 Lisp) might be changed to be tied to the selected frame instead.
1355 Currently, `function-key-map' and `key-translation-map' may be
1356 accessed reliably only using the hackish
1357 `(set-)terminal-local-value' functions.
1358
1359 Perhaps there should be a difference between `last-command' &co.
1360 and these more conventional configuration variables.
1361 (E.g. `symbol-value' would use current_kboard to access
1362 `last-command', but SELECTED_FRAME()->display->kboard to get the
1363 value of `function-key-map'.
1364
1365 (Fixed in patch-434.)
1366
1367-- If the first key pressed on a new tty terminal is a function key,
1368 it is not recognized correctly. May be related to the bug below.
1369
1370 (Seems to have been fixed as a side effect of patch-434. "The bug
d6805803
KL
1371 below" was the set-input-mode madness.)
1372
1373 (Update: this bug was fixed for good in patch-449. It was tracked
1374 down to a bug in `read_key_sequence': it failed to reinitialize its
1375 local function-key-map/key-translation-map references when it
1376 switched keyboards. I don't understand why did this bug only
1377 appear on brand new frames, though!)
9684e4c9 1378
5f6a587f
KL
1379-- Disable connecting to a new X display when we use the GTK toolkit.
1380
1381 (Disabled in patch-450.)
1382
f105f403
KL
1383-- Implement automatic forwarding of client environment variables to
1384 forked processes, as discussed on the multi-tty list. Terminal
1385 parameters are now accessible in C code, so the biggest obstacle is
1386 gone. The `getenv_internal' and `child_setup' functions in
1387 callproc.c must be changed to support the following variable:
1388
1389 terminal-local-environment-variables is a variable defined in ...
1390
1391 Enable or disable terminal-local environment variables.
1392
1393 If set to t, `getenv', `setenv' and subprocess creation
1394 functions use the environment variables of the emacsclient
1395 process that created the selected frame, ignoring
1396 `process-environment'.
1397
1398 If set to nil, Emacs uses `process-environment' and ignores
1399 the client environment.
1400
1401 Otherwise, `terminal-local-environment-variables' should be a
1402 list of variable names (represented by Lisp strings) to look
1403 up in the client environment. The rest will come from
1404 `process-environment'.
1405
1406 (Implemented in patch-461; `terminal-getenv', `terminal-setenv' and
1407 `with-terminal-environment' are now replaced by extensions to
1408 `getenv' and `setenv', and the new `local-environment-variables'
1409 facility. Yay!)
1410
da8e8fc1
KL
1411 (Updated in patch-465 to fix the semantics of let-binding
1412 `process-environment'. `process-environment' was changed to
1413 override all local/global environment variables, and a new variable
1414 `global-environment' was introduced to have `process-environment's
1415 old meaning.)
1416
1417 (Updated in patch-466 to fix the case when two emacsclient sessions
1418 share the same terminal, but have different environment. The local
1419 environment lists are now stored as frame parameters, so the
1420 C-level terminal parameters are not strictly necessary any more.)
1421
526039df
KL
1422-- `Fdelete_frame' is called from various critical places where it is
1423 not acceptable for the frame deletion to fail, e.g. from
1424 x_connection_closed after an X error. `Fdelete_frame' now protects
1425 against `delete-frame-functions' throwing an error and preventing a
1426 frame delete. (patch-475)
1427
b3e6f69c
KL
1428-- Fix set-input-mode for multi-tty. It's a truly horrible interface;
1429 what if we'd blow it up into several separate functions (with a
1430 compatibility definition)?
1431
1432 (Done. See `set-input-interrupt-mode', `set-output-flow-control',
1433 `set-input-meta-mode' and `set-quit-char'.) (patch-457)
1434
1435-- Let-binding `overriding-terminal-local-map' on a brand new frame
1436 does not seem to work correctly. (See `fancy-splash-screens'.)
1437 The keymap seems to be set up right, but events go to another
1438 terminal. Or is it `unread-command-events' that gets Emacs
1439 confused? Investigate.
1440
1441 (Emacs was confused because a process filter entered
1442 `recursive-edit' while Emacs was reading input. I added support
1443 for this in the input system.) (patch-489)
1444
1445-- I smell something funny around pop_kboard's "deleted kboard" case.
1446 Determine what are the circumstances of this case, and fix any
1447 bug that comes to light.
1448
1449 (It happens simply because single_kboard's terminal is sometimes
1450 deleted while executing a command on it, for example the one that
1451 kills the terminal. There was no bug here, but I rewrote the whole
1452 single_kboard mess anyway.) (patch-489)
1453
6bbba5a6
KL
1454-- Understand Emacs's low-level input system (it's black magic) :-)
1455 What exactly does interrupt_input do? I tried to disable it for
1456 raw secondary tty support, but it does not seem to do anything
1457 useful. (Update: Look again. X unconditionally enables this, maybe
1458 that's why raw terminal support is broken again. I really do need
1459 to understand input.)
1460 (Update: I am starting to understand the read_key_sequence->read-char
1461 ->kbd_buffer_get_event->read_avail_input->read_socket_hook path. Yay!)
1462
1463 (Update: OK, it all seems so easy now (NOT). Input could be done
1464 synchronously (with wait_reading_process_input), or asynchronously
1465 by SIGIO or polling (SIGALRM). C-g either sets the Vquit_flag,
1466 signals a 'quit condition (when immediate_quit), or throws to
1467 `getcjmp' when Emacs was waiting for input when the C-g event
1468 arrived.)
1469
9688ff53
KL
1470-- Replace wrong_kboard_jmpbuf with a special return value of
1471 read_char. It is absurd that we use setjmp/longjmp just to return
1472 to the immediate caller.
1473
1474 (Done in patch-500.)
526039df 1475
28d440ab 1476;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
2a42d440 1477