diff lisp/server.el @ 83009:b2b37c85b00a

Numerous bugfixes and small improvements. lisp/bindings.el (mode-line-frame-identification): Use %T, not %F. lisp/faces.el (x-create-frame-with-faces): Added frame-creation-function parameter. (tty-create-frame-with-faces): Ditto. lisp/frame.el (frame-creation-function): Make it frame-local. (select-frame-set-input-focus): Use the window-system function, not the variable. lisp/server.el (server-handle-delete-tty): Make sure the client process is removed from server-clients after the delete-process call. It seems that the sentinel is not called. Added docs. (server-process-filter): Immediately add the client to server-clients when a new termcap frame is created. Fixed a case of `not' called with two parameters. Ignore errors while sending the evaluation result back to the client. (server-kill-buffer-query-function): Don't ask the user if the server process is already dead. lisp/term/x-win.el: Don't change mode-line-frame-identification. src/buffer.c (syms_of_buffer): Added %T to the docs of mode-line-format. src/dispnew.c (init_display): Increment the reference count of the new termcap display. src/frame.c (make_terminal_frame): Set the old top frame's visibility to `obscured'. (Fmake_terminal_frame): Look at the current termcap display's name, not just the similar frame parameter. Try to get the type from the current display first, and only then from Vdefault_frame_alist. src/keyboard.c (handle_interrupt): New function to separate the signal handling from C-g processing. (interrupt_signal): Call handle_interrupt to do the real work. (kbd_buffer_store_event): Use handle_interrupt instead of interrupt_signal. (cmd_error_internal): Use FRAME_INITIAL_P instead of ugly hacks. src/termhooks.h (initial_display): New declaration. src/xdisp.c (decode_mode_spec): Added '%T' (termcap-only frame name). git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-49
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 10 Jan 2004 12:56:22 +0000
parents 039bd6989d29
children 1d2f73785d9d
line wrap: on
line diff
--- a/lisp/server.el	Fri Jan 09 18:57:53 2004 +0000
+++ b/lisp/server.el	Sat Jan 10 12:56:22 2004 +0000
@@ -212,13 +212,18 @@
   (server-log (format "Status changed to %s" (process-status proc)) proc))
 
 (defun server-handle-delete-tty (tty)
+  "Delete the client connection when the emacsclient frame is deleted."
   (dolist (entry server-ttys)
     (let ((proc (nth 0 entry))
 	  (term (nth 1 entry)))
       (when (equal term tty)
 	(let ((client (assq proc server-clients)))
 	  (setq server-ttys (delq entry server-ttys))
-	  (delete-process (car client)))))))
+	  (delete-process (car client))
+	  (when (assq proc server-clients)
+	    ;; This seems to be necessary to handle
+	    ;; `emacsclient -t -e '(delete-frame)'' correctly.
+	    (setq server-clients (delq client server-clients))))))))
 
 (defun server-select-display (display)
   ;; If the current frame is on `display' we're all set.
@@ -336,6 +341,7 @@
 			      (or file-name-coding-system
 				  default-file-name-coding-system)))
 	  client nowait eval newframe
+	  registered	; t if the client is already added to server-clients.
 	  (files nil)
 	  (lineno 1)
 	  (columnno 0))
@@ -363,11 +369,13 @@
 	      (condition-case err
 		  (let ((frame (make-frame-on-tty tty type)))
 		    (setq server-ttys (cons (list (car client) (frame-tty-name frame)) server-ttys))
-		    (sit-for 0)
 		    (process-send-string proc (concat "emacs-pid " (number-to-string (emacs-pid)) "\n"))
 		    (select-frame frame)
-		    (setq newframe t))
-		(error (ignore-errors (process-send-string proc (concat (nth 1 err) "\n")))
+		    ;; This makes sure that `emacsclient -t -e '(delete-frame)'' works right.
+		    (push client server-clients)
+		    (setq registered t
+			  newframe t))
+		(error (process-send-string proc (concat (nth 1 err) "\n"))
 		       (setq request "")))))
 	   ;; ARG is a line number option.
 	   ((string-match "\\`\\+[0-9]+\\'" arg)
@@ -386,12 +394,15 @@
 	    (if eval
 		(condition-case err
 		    (let ((v (eval (car (read-from-string arg)))))
-		      (when (and (not newframe v))
+		      (when (and (not newframe) v)
 			(with-temp-buffer
 			  (let ((standard-output (current-buffer)))
 			    (pp v)
 			    (process-send-region proc (point-min) (point-max))))))
-		  (error (process-send-string proc (concat "*Error* " (error-message-string err)))))
+		  (error
+		   (ignore-errors
+		     (process-send-string
+		      proc (concat "*Error* " (error-message-string err))))))
 
 	      ;; ARG is a file name.
 	      ;; Collapse multiple slashes to single slashes.
@@ -410,7 +421,7 @@
 	    (delete-process proc)
 	    (server-log "Close empty client" proc))
 	;; We visited some buffer for this client.
-	(or nowait (push client server-clients))
+	(or nowait registered (push client server-clients))
 	(unless (or isearch-mode (minibufferp))
 	  (if (and newframe (null (cdr client)))
 	      (message (substitute-command-keys
@@ -571,6 +582,11 @@
 ;; using whatever is on disk in that file. -- rms.
 (defun server-kill-buffer-query-function ()
   (or (not server-buffer-clients)
+      (let ((res t))
+	(dolist (proc server-buffer-clients res)
+	  (setq proc (assq proc server-clients))
+	  (when (and proc (eq (process-status (car proc)) 'open))
+	    (setq res nil))))
       (yes-or-no-p (format "Buffer `%s' still has clients; kill it? "
 			   (buffer-name (current-buffer))))))