changeset 83172:1a136b47986d

Don't leave buffers created by nowait clients buried under others (rep. by Dan Nicolaescu). * lisp/server.el (server-process-filter): Select buffers opened by nowait clients, don't leave them buried under others. (Reported by Dan Nicolaescu.) (server-visit-files): Return list of buffers created. Update doc. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-212
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 10 Jul 2004 20:56:57 +0000
parents 09bbf2fc80da
children 6b4b299e2cd5
files lisp/server.el
diffstat 1 files changed, 35 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/server.el	Sat Jul 10 14:37:36 2004 +0000
+++ b/lisp/server.el	Sat Jul 10 20:56:57 2004 +0000
@@ -590,38 +590,34 @@
 		 ;; Unknown command.
 		 (t (error "Unknown command: %s" arg)))))
 
-	    (when files
-	      (run-hooks 'pre-command-hook)
-	      (server-visit-files files client nowait)
-	      (run-hooks 'post-command-hook))
+	    (let (buffers)
+	      (when files
+		(run-hooks 'pre-command-hook)
+		(setq buffers (server-visit-files files client nowait))
+		(run-hooks 'post-command-hook))
 
-	    ;; Delete the client if necessary.
-	    (cond
-	     (nowait
-	      ;; Client requested nowait; return immediately.
-	      (server-log "Close nowait client" proc)
-	      (server-delete-client proc))
-	     ((and (not dontkill)
-		   (null (server-client-get client 'buffers)))
-	      ;; This client is empty; get rid of it immediately.
-	      (server-log "Close empty client" proc)
-	      (server-delete-client proc))
-	     (t
-	      (let ((buffers (server-client-get client 'buffers)))
-		(when buffers
-		  ;; We visited some buffer for this client.
-		  (cond
-		   ((or isearch-mode (minibufferp))
-		    nil)
-		   ((and frame (null buffers))
-		    (message (substitute-command-keys
-			      "When done with this frame, type \\[delete-frame]")))
-		   ((not (null buffers))
-		    (server-switch-buffer (car buffers))
-		    (run-hooks 'server-switch-hook)
-		    (unless nowait
-		      (message (substitute-command-keys
-				"When done with a buffer, type \\[server-edit]")))))))))))
+	      ;; Delete the client if necessary.
+	      (cond
+	       (nowait
+		;; Client requested nowait; return immediately.
+		(server-log "Close nowait client" proc)
+		(server-delete-client proc))
+	       ((and (not dontkill) (null buffers))
+		;; This client is empty; get rid of it immediately.
+		(server-log "Close empty client" proc)
+		(server-delete-client proc)))
+	      (cond
+	       ((or isearch-mode (minibufferp))
+		nil)
+	       ((and frame (null buffers))
+		(message (substitute-command-keys
+			  "When done with this frame, type \\[delete-frame]")))
+	       ((not (null buffers))
+		(server-switch-buffer (car buffers))
+		(run-hooks 'server-switch-hook)
+		(unless nowait
+		  (message (substitute-command-keys
+			    "When done with a buffer, type \\[server-edit]"))))))))
 
 	;; Save for later any partial line that remains.
 	(when (> (length string) 0)
@@ -641,7 +637,7 @@
 	(move-to-column (1- column-number)))))
 
 (defun server-visit-files (files client &optional nowait)
-  "Find FILES and return the list CLIENT with the buffers nconc'd.
+  "Find FILES and return a list of buffers created.
 FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER).
 NOWAIT non-nil means this client is not waiting for the results,
 so don't mark these buffers specially, just visit them normally."
@@ -676,11 +672,13 @@
 	(unless nowait
 	  ;; When the buffer is killed, inform the clients.
 	  (add-hook 'kill-buffer-hook 'server-kill-buffer nil t)
-	  (push (car client) server-buffer-clients)
-	  (push (current-buffer) client-record))))
-    (server-client-set
-     client 'buffers
-     (nconc (server-client-get client 'buffers) client-record))))
+	  (push (car client) server-buffer-clients))
+	(push (current-buffer) client-record)))
+    (unless nowait
+      (server-client-set
+       client 'buffers
+       (nconc (server-client-get client 'buffers) client-record)))
+    client-record))
 
 (defun server-buffer-done (buffer &optional for-killing)
   "Mark BUFFER as \"done\" for its client(s).