From b0eaaf736637f3ae677fd5a090e7317cb76ab2a4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 28 Oct 2025 11:08:53 -0700 Subject: [PATCH] More reliably check if a frame is the daemon's initial frame Frames created when Emacs is running as a daemon may not have the "client" frame parameter set, e.g., when: 1. Created from the user's init file. 2. Created via "emacsclient -e" (e.g., "emacsclient -e '(make-frame)'"). The "client" parameter simply indicates that the frame was created by emacsclient directly (or recursively from another emacsclient frame). Instead, this commit checks if (a) Emacs is running as a daemon and (b) the target frame is the "terminal frame". When run as a daemon, Emacs's terminal frame is always the daemon's initial frame. * lisp/desktop.el (desktop-clear): (desktop-restoring-frameset-p): * lisp/display-fill-column-indicator.el (display-fill-column-indicator--turn-on): * lisp/frame.el (frame-notice-user-settings): * lisp/obsolete/linum.el (linum-on): * lisp/progmodes/flymake.el (flymake-start): * lisp/tab-bar.el (tab-bar--update-tab-bar-lines): Fix the "is this the initial daemon-frame" checks. (Bug#79686) --- lisp/desktop.el | 4 ++-- lisp/display-fill-column-indicator.el | 2 +- lisp/frame.el | 2 +- lisp/obsolete/linum.el | 2 +- lisp/progmodes/flymake.el | 2 +- lisp/tab-bar.el | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/desktop.el b/lisp/desktop.el index b82a9dc9626..21a742c9aad 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -775,7 +775,7 @@ if different)." ;; Don't delete daemon's initial frame, or ;; we'll never be able to close the last ;; client's frame (Bug#26912). - (if (daemonp) (not (frame-parameter frame 'client))) + (and (daemonp) (eq frame terminal-frame)) (frame-parameter frame 'desktop-dont-clear)) (delete-frame frame)) (error @@ -1255,7 +1255,7 @@ This function also sets `desktop-dirname' to nil." (and desktop-restore-frames desktop-saved-frameset ;; Don't restore frames when the selected frame is the daemon's ;; initial frame. - (not (and (daemonp) (not (frame-parameter nil 'client)))) + (not (and (daemonp) (eq (selected-frame) terminal-frame))) t)) (defun desktop-restore-frameset () diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el index dbd067f5f3d..4598b659341 100644 --- a/lisp/display-fill-column-indicator.el +++ b/lisp/display-fill-column-indicator.el @@ -102,7 +102,7 @@ See Info node `Displaying Boundaries' for details." (defun display-fill-column-indicator--turn-on () "Turn on `display-fill-column-indicator-mode'." (unless (or (minibufferp) - (and (daemonp) (null (frame-parameter nil 'client)))) + (and (daemonp) (eq (selected-frame) terminal-frame))) (display-fill-column-indicator-mode))) ;;;###autoload diff --git a/lisp/frame.el b/lisp/frame.el index b6641ca716a..6e18ba65d9a 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -493,7 +493,7 @@ there (in decreasing order of priority)." (setq parms (append initial-frame-alist window-system-frame-alist default-frame-alist parms nil)) ;; Don't enable tab-bar in daemon's initial frame. - (when (and (daemonp) (not (frame-parameter nil 'client))) + (when (and (daemonp) (eq (selected-frame) terminal-frame)) (setq parms (delq (assq 'tab-bar-lines parms) parms))) parms)) (if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el diff --git a/lisp/obsolete/linum.el b/lisp/obsolete/linum.el index e0782258716..75cb1199927 100644 --- a/lisp/obsolete/linum.el +++ b/lisp/obsolete/linum.el @@ -129,7 +129,7 @@ Linum mode is a buffer-local minor mode." ;; Note that nowadays, this actually doesn't show line ;; numbers in client frames at all, because we visit the ;; file before creating the client frame. See bug#35726. - (and (daemonp) (null (frame-parameter nil 'client)))) + (and (daemonp) (eq (selected-frame) terminal-frame))) (linum-mode 1))) (defun linum-delete-overlays () diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 7af4ea334d6..60a6bacf640 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1390,7 +1390,7 @@ Interactively, with a prefix arg, FORCE is t." (cl-labels ((visible-buffer-window () (and (or (not (daemonp)) - (not (null (frame-parameter nil 'client)))) + (not (eq (selected-frame) terminal-frame))) (get-buffer-window (current-buffer)))) (start-post-command () (remove-hook 'post-command-hook #'start-post-command diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index db16775d884..6653d12f634 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -282,7 +282,7 @@ a list of frames to update." (and (eq auto-resize-tab-bars 'grow-only) (> (frame-parameter frame 'tab-bar-lines) 1)) ;; Don't enable tab-bar in daemon's initial frame. - (and (daemonp) (not (frame-parameter frame 'client)))) + (and (daemonp) (eq frame terminal-frame))) (set-frame-parameter frame 'tab-bar-lines (tab-bar--tab-bar-lines-for-frame frame))))) ;; Update `default-frame-alist'