From ffb6157eccc8e08ae5c5ea3bb81136ad5bad4d29 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Wed, 8 Feb 2012 09:02:17 +0100 Subject: [PATCH] In server-unselect-display don't inadvertently kill current buffer. (Bug#10729) * server.el (server-unselect-display): Don't inadvertently kill the current buffer. (Bug#10729) --- lisp/ChangeLog | 5 +++++ lisp/server.el | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9cda0d38acb..06f55e23e24 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-02-08 Martin Rudalics + + * server.el (server-unselect-display): Don't inadvertently kill + the current buffer. (Bug#10729) + 2012-02-08 Glenn Morris * progmodes/sql.el (sql-port, sql-connection-alist, sql-list-all) diff --git a/lisp/server.el b/lisp/server.el index a08f971e88c..79858e6d83e 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -399,16 +399,18 @@ If CLIENT is non-nil, add a description of it to the logged message." ;; visible. If not (which can happen if the user's customizations call ;; pop-to-buffer etc.), delete it to avoid preserving the connection after ;; the last real frame is deleted. - (if (and (eq (frame-first-window frame) - (next-window (frame-first-window frame) 'nomini)) - (eq (window-buffer (frame-first-window frame)) - (frame-parameter frame 'server-dummy-buffer))) - ;; The temp frame still only shows one buffer, and that is the - ;; internal temp buffer. - (delete-frame frame) - (set-frame-parameter frame 'visibility t)) - (kill-buffer (frame-parameter frame 'server-dummy-buffer)) - (set-frame-parameter frame 'server-dummy-buffer nil))) + + ;; Rewritten to avoid inadvertently killing the current buffer after + ;; `delete-frame' removed FRAME (Bug#10729). + (let ((buffer (frame-parameter frame 'server-dummy-buffer))) + (if (and (one-window-p 'nomini frame) + (eq (window-buffer (frame-first-window frame)) buffer)) + ;; The temp frame still only shows one buffer, and that is the + ;; internal temp buffer. + (delete-frame frame) + (set-frame-parameter frame 'visibility t) + (set-frame-parameter frame 'server-dummy-buffer nil)) + (kill-buffer buffer)))) (defun server-handle-delete-frame (frame) "Delete the client connection when the emacsclient frame is deleted. -- 2.39.2