bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65277: 29.1.50; emacsclient Dired: frame is closed/killed when openi


From: Eli Zaretskii
Subject: bug#65277: 29.1.50; emacsclient Dired: frame is closed/killed when opening another dir
Date: Thu, 17 Aug 2023 22:02:16 +0300

> Cc: 65277@debbugs.gnu.org
> Date: Thu, 17 Aug 2023 12:44:47 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
> Thanks for testing.  Could you please test the improved patch below?

Sorry, that patch had a silly mistake.  Please use the one below
instead:

diff --git a/lisp/files.el b/lisp/files.el
index 68c0a10..3466a53 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 'dont-kill-client))
+      (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..1ae1e12 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 '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;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]