From 5f3c1a63f31f77f60b8a60518ce3eda6a51f72b9 Mon Sep 17 00:00:00 2001 From: Karoly Lorentey Date: Thu, 23 Feb 2006 02:59:27 +0000 Subject: [PATCH] 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 --- README.multi-tty | 6 ++++++ lisp/server.el | 30 +++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.multi-tty b/README.multi-tty index 49a3f7b92bf..da3ab4ade5b 100644 --- a/README.multi-tty +++ b/README.multi-tty @@ -479,10 +479,16 @@ THINGS TO DO 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 diff --git a/lisp/server.el b/lisp/server.el index 12a56599185..86dd9a8e469 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -107,7 +107,7 @@ Each element is (PROC PROPERTIES...) where PROC is a process object, 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 @@ ENV should be in the same format as `process-environment'." (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 @@ If NOFRAME is non-nil, let the frames live. (To be used from (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 @@ so don't mark these buffers specially, just visit them normally." (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) -- 2.11.4.GIT