diff options
| author | Eli Zaretskii | 2023-08-19 10:34:07 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-08-19 10:34:07 +0300 |
| commit | e3207b13ce5acbae89441e06c19ae4df7988004e (patch) | |
| tree | e78b519e499cd056ad735ed001e24797579c2612 /lisp/server.el | |
| parent | b12ce748d1a6bcb84667097012eae4c2d249ba00 (diff) | |
| download | emacs-e3207b13ce5acbae89441e06c19ae4df7988004e.tar.gz emacs-e3207b13ce5acbae89441e06c19ae4df7988004e.zip | |
Fix behavior of client frames when 'find-alternate-file' is used
* lisp/files.el (find-alternate-file-dont-kill-client): New var.
(find-alternate-file): Bind it to a special value when invoking
kill-buffer-hook.
* lisp/server.el (server-delete-client): If NOFRAME is
'dont-kill-client', don't kill the client and its terminals.
(server-buffer-done): Pass 'find-alternate-file-dont-kill-client'
to 'server-delete-client'. (Bug#65277)
Diffstat (limited to 'lisp/server.el')
| -rw-r--r-- | lisp/server.el | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lisp/server.el b/lisp/server.el index ba7e02d2555..10f15598221 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -330,6 +330,9 @@ ENV should be in the same format as `process-environment'." | |||
| 330 | (defun server-delete-client (proc &optional noframe) | 330 | (defun server-delete-client (proc &optional noframe) |
| 331 | "Delete PROC, including its buffers, terminals and frames. | 331 | "Delete PROC, including its buffers, terminals and frames. |
| 332 | If NOFRAME is non-nil, let the frames live. | 332 | If NOFRAME is non-nil, let the frames live. |
| 333 | If NOFRAME is the symbol \\='dont-kill-client, also don't | ||
| 334 | delete PROC or its terminals, just kill its buffers: this is | ||
| 335 | for when `find-alternate-file' calls this via `kill-buffer-hook'. | ||
| 333 | Updates `server-clients'." | 336 | Updates `server-clients'." |
| 334 | (server-log (concat "server-delete-client" (if noframe " noframe")) proc) | 337 | (server-log (concat "server-delete-client" (if noframe " noframe")) proc) |
| 335 | ;; Force a new lookup of client (prevents infinite recursion). | 338 | ;; Force a new lookup of client (prevents infinite recursion). |
| @@ -366,23 +369,28 @@ Updates `server-clients'." | |||
| 366 | (set-frame-parameter frame 'client nil) | 369 | (set-frame-parameter frame 'client nil) |
| 367 | (delete-frame frame)))) | 370 | (delete-frame frame)))) |
| 368 | 371 | ||
| 369 | (setq server-clients (delq proc server-clients)) | 372 | (or (eq noframe 'dont-kill-client) |
| 373 | (setq server-clients (delq proc server-clients))) | ||
| 370 | 374 | ||
| 371 | ;; Delete the client's tty, except on Windows (both GUI and | 375 | ;; Delete the client's tty, except on Windows (both GUI and |
| 372 | ;; console), where there's only one terminal and does not make | 376 | ;; console), where there's only one terminal and does not make |
| 373 | ;; sense to delete it, or if we are explicitly told not. | 377 | ;; sense to delete it, or if we are explicitly told not. |
| 374 | (unless (or (eq system-type 'windows-nt) | 378 | (unless (or (eq system-type 'windows-nt) |
| 379 | ;; 'find-alternate-file' caused the last client | ||
| 380 | ;; buffer to be killed, but we will reuse the client | ||
| 381 | ;; for another buffer. | ||
| 382 | (eq noframe 'dont-kill-client) | ||
| 375 | (process-get proc 'no-delete-terminal)) | 383 | (process-get proc 'no-delete-terminal)) |
| 376 | (let ((terminal (process-get proc 'terminal))) | 384 | (let ((terminal (process-get proc 'terminal))) |
| 377 | ;; Only delete the terminal if it is non-nil. | 385 | ;; Only delete the terminal if it is non-nil. |
| 378 | (when (and terminal (eq (terminal-live-p terminal) t)) | 386 | (when (and terminal (eq (terminal-live-p terminal) t)) |
| 379 | (delete-terminal terminal)))) | 387 | (delete-terminal terminal)))) |
| 380 | 388 | ||
| 381 | ;; Delete the client's process. | 389 | ;; Delete the client's process (or don't). |
| 382 | (if (eq (process-status proc) 'open) | 390 | (unless (eq noframe 'dont-kill-client) |
| 383 | (delete-process proc)) | 391 | (if (eq (process-status proc) 'open) |
| 384 | 392 | (delete-process proc)) | |
| 385 | (server-log "Deleted" proc)))) | 393 | (server-log "Deleted" proc))))) |
| 386 | 394 | ||
| 387 | (defvar server-log-time-function #'current-time-string | 395 | (defvar server-log-time-function #'current-time-string |
| 388 | "Function to generate timestamps for `server-buffer'.") | 396 | "Function to generate timestamps for `server-buffer'.") |
| @@ -1590,7 +1598,8 @@ FOR-KILLING if non-nil indicates that we are called from `kill-buffer'." | |||
| 1590 | ;; frames, which might change the current buffer. We | 1598 | ;; frames, which might change the current buffer. We |
| 1591 | ;; don't want that (bug#640). | 1599 | ;; don't want that (bug#640). |
| 1592 | (save-current-buffer | 1600 | (save-current-buffer |
| 1593 | (server-delete-client proc)) | 1601 | (server-delete-client proc |
| 1602 | find-alternate-file-dont-kill-client)) | ||
| 1594 | (server-delete-client proc)))))) | 1603 | (server-delete-client proc)))))) |
| 1595 | (when (and (bufferp buffer) (buffer-name buffer)) | 1604 | (when (and (bufferp buffer) (buffer-name buffer)) |
| 1596 | ;; We may or may not kill this buffer; | 1605 | ;; We may or may not kill this buffer; |