From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65277: 29.1.50; emacsclient Dired: frame is closed/killed when opening another dir Date: Thu, 17 Aug 2023 12:44:47 +0300 Message-ID: <83ttsy57g0.fsf@gnu.org> References: <87350mpkho.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40512"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65277@debbugs.gnu.org To: brickviking Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 17 11:45:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qWZZC-000AJa-JN for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Aug 2023 11:45:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWZYv-0001tk-Fc; Thu, 17 Aug 2023 05:45:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWZYt-0001s0-6J for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 05:45:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWZYs-00087M-Lk for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 05:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qWZYs-0000LR-Gj for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 05:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Aug 2023 09:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65277 X-GNU-PR-Package: emacs Original-Received: via spool by 65277-submit@debbugs.gnu.org id=B65277.16922654871289 (code B ref 65277); Thu, 17 Aug 2023 09:45:02 +0000 Original-Received: (at 65277) by debbugs.gnu.org; 17 Aug 2023 09:44:47 +0000 Original-Received: from localhost ([127.0.0.1]:42785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWZYc-0000Ki-Tq for submit@debbugs.gnu.org; Thu, 17 Aug 2023 05:44:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWZYa-0000KU-Nc for 65277@debbugs.gnu.org; Thu, 17 Aug 2023 05:44:45 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWZYV-000848-HF; Thu, 17 Aug 2023 05:44:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=FY0fSp9QnqCTgv39VrRXVk+/iwsuNTAi4McXUKGvqO8=; b=Nudlh7dOl1Vo GLq740PS023dc2Gg8OOiF7bKHS4nqwP9y3tJ8FR/KD5k+qH35KreQJNXzSNzZuCVjuCMttIi312+X dhPkPdm0Noj1uRClFgbm/P99JpgOU3MsBPTkxuL9UX8ZAjk4oftbXFyU8vWy4bNJXa8Z0pWwHxXpV FlFz3FBhaALkk8rIgfCmxCaPg7KTPXSuWSVSnjh9OmXaZ/A0ydBwqpSzOY/OX+3sQb234VDd6RpoL YkxgGp3me/2Ynqp9IwemIQPdABBQ33vK+wDPn7cfWbvB5pouwAtzKLD7b4MLTybgaKMO5ktDy3Gvs 2/fwcAHEYgTUyw+KzrWYSA==; In-Reply-To: (message from brickviking on Wed, 16 Aug 2023 18:37:59 +1200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267648 Archived-At: > From: brickviking > Date: Wed, 16 Aug 2023 18:37:59 +1200 > > Further to the above tests from me which were in graphics mode, I also did the same test with > textmode as follows: > > shell1$ emacs -Q # in graphics mode > A frame renders, I then start up the server: > M-x server-start > > That frame stays around. Going off to another shell, I started an emacsclient, but this time in text > mode. > > shell2$ emacsclient -t GNUmakefile > > The terminal is cleared, and the contents of GNUmakefile appear. A buffer is assigned, as I can tell in > C-x C-b in the original server window. > > In the minibuffer (of the emacsclient) I then go: > C-x C-v INSTALL > and the terminal returns to the shell prompt. Interestingly, the contents of INSTALL then appear in the > original emacs server window, and in the buffer listing, GNUmakefile has been replaced by INSTALL > when I refresh the buffer listing. > > My conclusion is that this bug hasn't exactly been "fixed" with the patches to files.el and server.el, but > at least in graphics mode the frame hangs around instead of the content turning up in the parent > frame with the server running. Thanks for testing. Could you please test the improved patch below? It includes the original changes you already tested, so please use it to patch the original files.el and server.el, not the versions already patched by the changes I sent earlier. diff --git a/lisp/files.el b/lisp/files.el index 68c0a10..cc17445 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1998,6 +1998,8 @@ kill-buffer-hook Note: Be careful with let-binding this hook considering it is frequently used for cleanup.") +(defvar find-alternate-file-dont-kill-client nil + "If non-nil, `server-buffer-done' should not delete the client.") (defun find-alternate-file (filename &optional wildcards) "Find file FILENAME, select its buffer, kill previous buffer. If the current buffer now contains an empty file that you just visited @@ -2044,7 +2046,8 @@ find-alternate-file ;; save a modified buffer visiting a file. Rather, `kill-buffer' ;; asks that itself. Thus, there's no need to temporarily do ;; `(set-buffer-modified-p nil)' before running this hook. - (run-hooks 'kill-buffer-hook) + (let ((find-alternate-file-dont-kill-client t)) + (run-hooks 'kill-buffer-hook)) ;; Okay, now we can end-of-life the old buffer. (if (get-buffer " **lose**") (kill-buffer " **lose**")) diff --git a/lisp/server.el b/lisp/server.el index ba7e02d..e616d59 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -372,6 +372,10 @@ server-delete-client ;; console), where there's only one terminal and does not make ;; sense to delete it, or if we are explicitly told not. (unless (or (eq system-type 'windows-nt) + ;; 'find-alternate-file' caused the last client + ;; buffer to be killed, but we will reuse the client + ;; for another buffer. + (eq noframe 'find-alternate-file-dont-kill-client) (process-get proc 'no-delete-terminal)) (let ((terminal (process-get proc 'terminal))) ;; Only delete the terminal if it is non-nil. @@ -1590,7 +1594,8 @@ server-buffer-done ;; frames, which might change the current buffer. We ;; don't want that (bug#640). (save-current-buffer - (server-delete-client proc)) + (server-delete-client proc + find-alternate-file-dont-kill-client)) (server-delete-client proc)))))) (when (and (bufferp buffer) (buffer-name buffer)) ;; We may or may not kill this buffer;