# HG changeset patch # User Karoly Lorentey # Date 1072533354 0 # Node ID e77dcb66ec843c1298fc590e0a8650f25675c70b # Parent 1bf332eccca1333bbe46dde124d93bfd1288d1c6 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 diff -r 1bf332eccca1 -r e77dcb66ec84 README.multi-tty --- 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. diff -r 1bf332eccca1 -r e77dcb66ec84 lisp/server.el --- 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. diff -r 1bf332eccca1 -r e77dcb66ec84 src/frame.c --- 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