changeset 83477:3a9507e5aa39

Fix `server-delete-client' behavior when the user quits `kill-buffer'. (Reported by Han Boetes.) * lisp/server.el (server-buffer-clients): Doc update. (server-delete-client): Handle quits in kill-buffer. Don't kill modified buffers. Add extra logging. (server-visit-files): Don't set `server-existing-buffer' if the buffer already has other clients. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-517
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 23 Feb 2006 02:59:27 +0000
parents 866effff65a4
children 856efda75a1b
files README.multi-tty lisp/server.el
diffstat 2 files changed, 27 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/README.multi-tty	Tue Feb 21 15:57:00 2006 +0000
+++ b/README.multi-tty	Thu Feb 23 02:59:27 2006 +0000
@@ -479,10 +479,16 @@
    multidisplay (and don't mind core dumps), you can edit src/config.h
    and define HAVE_GTK_MULTIDISPLAY there by hand.
    
+	http://bugzilla.gnome.org/show_bug.cgi?id=85715
+
    Update: Han reports that GTK+ version 2.8.9 almost gets display
    disconnects right.  GTK will probably be fully fixed by the time
    multi-tty gets into the trunk.
 
+   Update: I am still having problems with GTK+ 2.8.10.  I have the
+   impression that the various multidisplay fixes will only get
+   released in GTK+ 2.10.
+
 ** Audit `face-valid-attribute-values' usage in customize and
    elsewhere.  Its return value depends on the current window system.
    Replace static initializers using it with runtime functions.  For
--- a/lisp/server.el	Tue Feb 21 15:57:00 2006 +0000
+++ b/lisp/server.el	Thu Feb 23 02:59:27 2006 +0000
@@ -107,7 +107,7 @@
 and PROPERTIES is an association list of client properties.")
 
 (defvar server-buffer-clients nil
-  "List of client ids for clients requesting editing of current buffer.")
+  "List of client processes requesting editing of current buffer.")
 (make-variable-buffer-local 'server-buffer-clients)
 ;; Changing major modes should not erase this local.
 (put 'server-buffer-clients 'permanent-local t)
@@ -249,26 +249,35 @@
 (defun server-delete-client (client &optional noframe)
   "Delete CLIENT, including its buffers, terminals and frames.
 If NOFRAME is non-nil, let the frames live.  (To be used from
-`delete-frame-functions'."
+`delete-frame-functions'.)"
+  (server-log (concat "server-delete-client" (if noframe " noframe"))
+	      client)
   ;; Force a new lookup of client (prevents infinite recursion).
   (setq client (server-client
 		(if (listp client) (car client) client)))
   (let ((proc (car client))
 	(buffers (server-client-get client 'buffers)))
     (when client
-      (setq server-clients (delq client server-clients))
 
+      ;; Kill the client's buffers.
       (dolist (buf buffers)
 	(when (buffer-live-p buf)
 	  (with-current-buffer buf
-	    ;; Remove PROC from the clients of each buffer.
-	    (setq server-buffer-clients (delq proc server-buffer-clients))
 	    ;; Kill the buffer if necessary.
-	    (when (and (null server-buffer-clients)
+	    (when (and (equal server-buffer-clients
+			      (list proc))
 		       (or (and server-kill-new-buffers
 				(not server-existing-buffer))
-			   (server-temp-file-p)))
-	      (kill-buffer (current-buffer))))))
+			   (server-temp-file-p))
+		       (not (buffer-modified-p)))
+	      (let (flag)
+		(unwind-protect
+		    (progn (setq server-buffer-clients nil)
+			   (kill-buffer (current-buffer))
+			   (setq flag t))
+		  (unless flag
+		    ;; Restore clients if user pressed C-g in `kill-buffer'.
+		    (setq server-buffer-clients (list proc)))))))))
 
       ;; Delete the client's frames.
       (unless noframe
@@ -280,6 +289,8 @@
 	    (set-frame-parameter frame 'client nil)
 	    (delete-frame frame))))
 
+      (setq server-clients (delq client server-clients))
+
       ;; Delete the client's tty.
       (let ((terminal (server-client-get client 'terminal)))
 	(when (eq (terminal-live-p terminal) t)
@@ -844,7 +855,8 @@
 			    (concat "File no longer exists: " filen
 				    ", write buffer to file? "))
 			   (write-file filen))))
-		(setq server-existing-buffer t)
+		(unless server-buffer-clients
+		  (setq server-existing-buffer t))
 		(server-goto-line-column file))
 	    (set-buffer (find-file-noselect filen))
 	    (server-goto-line-column file)