changeset 53236:e77dcb66ec84

Implemented automatic deletion of terminals. lisp/server.el (server-process-filter): Switch to the new terminal frame. src/frame.c (Fdelete_frame): Delete the tty if this was its the last frame. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-12
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 27 Dec 2003 13:55:54 +0000
parents 1bf332eccca1
children 4f33c6fc9a1f
files README.multi-tty lisp/server.el src/frame.c
diffstat 3 files changed, 33 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/README.multi-tty	Sat Dec 27 13:13:46 2003 +0000
+++ b/README.multi-tty	Sat Dec 27 13:55:54 2003 +0000
@@ -180,6 +180,11 @@
    initialization.  There is a memory corruption error around this
    somewhere.)
 
+-- Implement automatic deletion of terminals when the last frame on
+   that terminal is closed.
+
+   (Done.)
+
 
 THINGS TO DO
 ------------
@@ -200,16 +205,16 @@
    Update: yes it does, although it is much rarer.  Or maybe it's
    another bug.
 
-** C-g should work on secondary terminals.
+** Change emacsclient/server.el to support the -h argument better,
+   i.e. automatically close the socket when the frame is closed.
 
-** Implement automatic deletion of terminals when the last frame on
-   that terminal is closed.
+** 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.
 
-** Export delete_tty to the Lisp environment, for emacsclient.
-
 ** Implement support for starting an interactive Emacs session without
    an initial frame.  (The user would connect to it and open frames
    later, with emacsclient.)  Not necessarily a good idea.
--- a/lisp/server.el	Sat Dec 27 13:13:46 2003 +0000
+++ b/lisp/server.el	Sat Dec 27 13:55:54 2003 +0000
@@ -325,9 +325,9 @@
 		  (type (server-unquote-arg (match-string 2 request))))
 	      (setq request (substring request (match-end 0)))
 	      (condition-case err
-		  (progn
-		    (make-terminal-frame `((tty . ,pty) (tty-type . ,type)))
-		    (process-send-string proc (concat (number-to-string (emacs-pid)) "\n")))
+		  (let ((frame (make-terminal-frame `((tty . ,pty) (tty-type . ,type)))))
+		    (process-send-string proc (concat (number-to-string (emacs-pid)) "\n"))
+		    (select-frame frame))
 		(error (process-send-string proc (nth 1 err))
 		       (setq request "")))))
 	   ;; ARG is a line number option.
--- a/src/frame.c	Sat Dec 27 13:13:46 2003 +0000
+++ b/src/frame.c	Sat Dec 27 13:55:54 2003 +0000
@@ -1381,6 +1381,26 @@
     x_destroy_window (f);
 #endif
 
+  if (FRAME_TERMCAP_P (f))
+    {
+      /* See if the terminal needs to be closed. */
+      Lisp_Object tail, frame1;
+      int delete = 1;
+      
+      FOR_EACH_FRAME (tail, frame1)
+        {
+          if (!FRAME_LIVE_P (XFRAME (frame1)) &&
+              FRAME_TERMCAP_P (XFRAME (frame1)) &&
+              FRAME_TTY (XFRAME (frame1)) == FRAME_TTY (f))
+            {
+              delete = 0;
+              break;
+            }
+        }
+      if (delete)
+        delete_tty (FRAME_TTY (f));
+    }
+      
   f->output_data.nothing = 0;
 
   /* If we've deleted the last_nonminibuf_frame, then try to find