Make sure secondary frames are deleted when emacsclient quits.
authorKaroly Lorentey <lorentey@elte.hu>
Mon, 29 Dec 2003 08:28:35 +0000 (08:28 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Mon, 29 Dec 2003 08:28:35 +0000 (08:28 +0000)
lisp/server.el (server-sentinel): Delete frame if alive.  Fix delq
invocation on server-frames.
(server-process-filter, server-buffer-done): Fix delq invocation on
server-frames.

src/cm.c (cmputc): Abort on write error, see what happens.

src/keyboard.c (read_avail_input): Do delete_tty on read errors.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-21

README.multi-tty
lisp/server.el
src/cm.c
src/keyboard.c

index ffa4b18..391562e 100644 (file)
@@ -198,6 +198,21 @@ DIARY OF CHANGES
    
    (Done.)
 
+-- C-g should work on secondary terminals.
+
+   (Done, but the binding is not configurable.)
+
+-- Deal with SIGHUP in Emacs and in emacsclient.  (After this, the
+   server-frames may be removed from server.el.)
+
+   (Done, nothing to do.  It seems that Emacs does not receive SIGHUP
+   from secondary ttys.)
+
+-- Change emacsclient/server.el to support the -h argument better,
+   i.e. automatically close the socket when the frame is closed.
+
+   (Seems to be working OK.)
+
 THINGS TO DO
 ------------
 
@@ -217,15 +232,13 @@ THINGS TO DO
    Update: yes it does, although it is much rarer.  Or maybe it's
    another bug.
 
-** Change emacsclient/server.el to support the -h argument better,
-   i.e. automatically close the socket when the frame is closed.
+** Make parts of struct tty_output accessible from Lisp.  The device
+   name and the type is sufficient.
 
 ** Export delete_tty to the Lisp environment, for emacsclient.
 
-** C-g should work on secondary terminals.
-
-** Make parts of struct tty_output accessible from Lisp.  The device
-   name and the type is sufficient.
+** Make sure C-g goes to the right frame.  This is hard, as SIGINT
+   doesn't have a tty parameter. :-(
 
 ** Find out why does Emacs abort when it wants to close its
    controlling tty.  Hint: chan_process[] array.  Hey, maybe
@@ -251,9 +264,6 @@ THINGS TO DO
 ** Find out the best way to support suspending Emacs with multiple
    ttys.
 
-** Deal with SIGHUP in Emacs and in emacsclient.  (After this, the
-   server-frames may be removed from server.el.)
-
 ** Do tty output through term_hooks, like all other display backends.
 
 ** Fix X support.
index d57739f..4016681 100644 (file)
@@ -185,7 +185,9 @@ are done with it in the server.")
     ;; Remove PROC from the list of clients.
     (when client
       (setq server-clients (delq client server-clients))
-      (setq server-frames (delq client server-frames))
+      (let ((frame (assq (car client) server-frames)))
+       (setq server-frames (delq frame server-frames))
+       (when (frame-live-p (cadr frame)) (delete-frame (cadr frame))))
       (dolist (buf (cdr client))
        (with-current-buffer buf
          ;; Remove PROC from the clients of each buffer.
@@ -378,9 +380,9 @@ PROC is the server process.  Format of STRING is \"PATH PATH PATH... \\n\"."
       (if (null (cdr client))
          ;; This client is empty; get rid of it immediately.
          (progn
-           (let ((frame (cadr (assq (car client) server-frames))))
-             ;; Close the client's frame.
-             (when frame (delete-frame frame)))
+           (let ((frame (assq (car client) server-frames)))
+             (setq server-frames (delq frame server-frames))
+             (when (frame-live-p (cadr frame)) (delete-frame (cadr frame))))
            (delete-process proc)
            (server-log "Close empty client" proc))
        ;; We visited some buffer for this client.
@@ -467,9 +469,9 @@ FOR-KILLING if non-nil indicates that we are called from `kill-buffer'."
        ;; If client now has no pending buffers,
        ;; tell it that it is done, and forget it entirely.
        (unless (cdr client)
-         (let ((frame (cadr (assq (car client) server-frames))))
-           ;; Close the client's frame.
-           (when frame (delete-frame frame)))
+         (let ((frame (assq (car client) server-frames)))
+           (setq server-frames (delq frame server-frames))
+           (when (frame-live-p (cadr frame)) (delete-frame (cadr frame))))
          (delete-process (car client))
          (server-log "Close" (car client))
          (setq server-clients (delq client server-clients))))
index 95aa6af..1094e30 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -70,7 +70,8 @@ cmputc (c)
 {
   if (TTY_TERMSCRIPT (current_tty))
     putc (c & 0177, TTY_TERMSCRIPT (current_tty));
-  putc (c & 0177, TTY_OUTPUT (current_tty));
+  if (putc (c & 0177, TTY_OUTPUT (current_tty)) == EOF)
+      abort ();                 /* XXX For testing only! */
   return c;
 }
 
index 217cc29..1bb9564 100644 (file)
@@ -6689,7 +6689,7 @@ read_avail_input (expected)
                 if (! tty_list->next)
                   kill (0, SIGHUP); /* This was the last terminal. */
                 else
-                  ;             /* XXX tty should be closed here. */
+                  delete_tty (tty); /* XXX I wonder if this is safe here. */
               }
 #if defined (AIX) && (! defined (aix386) && defined (_BSD))
             /* The kernel sometimes fails to deliver SIGHUP for ptys.
@@ -6701,7 +6701,7 @@ read_avail_input (expected)
                 if (! tty_list->next)
                   kill (0, SIGHUP); /* This was the last terminal. */
                 else
-                  ;             /* XXX tty should be closed here. */
+                  delete_tty (tty); /* XXX I wonder if this is safe here. */
               }
 #endif
           }