1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

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)
This commit is contained in:
Steven Allen 2025-10-28 11:08:53 -07:00 committed by Juri Linkov
parent 97d2a659e8
commit b0eaaf7366
6 changed files with 7 additions and 7 deletions

View file

@ -775,7 +775,7 @@ if different)."
;; Don't delete daemon's initial frame, or ;; Don't delete daemon's initial frame, or
;; we'll never be able to close the last ;; we'll never be able to close the last
;; client's frame (Bug#26912). ;; client's frame (Bug#26912).
(if (daemonp) (not (frame-parameter frame 'client))) (and (daemonp) (eq frame terminal-frame))
(frame-parameter frame 'desktop-dont-clear)) (frame-parameter frame 'desktop-dont-clear))
(delete-frame frame)) (delete-frame frame))
(error (error
@ -1255,7 +1255,7 @@ This function also sets `desktop-dirname' to nil."
(and desktop-restore-frames desktop-saved-frameset (and desktop-restore-frames desktop-saved-frameset
;; Don't restore frames when the selected frame is the daemon's ;; Don't restore frames when the selected frame is the daemon's
;; initial frame. ;; initial frame.
(not (and (daemonp) (not (frame-parameter nil 'client)))) (not (and (daemonp) (eq (selected-frame) terminal-frame)))
t)) t))
(defun desktop-restore-frameset () (defun desktop-restore-frameset ()

View file

@ -102,7 +102,7 @@ See Info node `Displaying Boundaries' for details."
(defun display-fill-column-indicator--turn-on () (defun display-fill-column-indicator--turn-on ()
"Turn on `display-fill-column-indicator-mode'." "Turn on `display-fill-column-indicator-mode'."
(unless (or (minibufferp) (unless (or (minibufferp)
(and (daemonp) (null (frame-parameter nil 'client)))) (and (daemonp) (eq (selected-frame) terminal-frame)))
(display-fill-column-indicator-mode))) (display-fill-column-indicator-mode)))
;;;###autoload ;;;###autoload

View file

@ -493,7 +493,7 @@ there (in decreasing order of priority)."
(setq parms (append initial-frame-alist window-system-frame-alist (setq parms (append initial-frame-alist window-system-frame-alist
default-frame-alist parms nil)) default-frame-alist parms nil))
;; Don't enable tab-bar in daemon's initial frame. ;; 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))) (setq parms (delq (assq 'tab-bar-lines parms) parms)))
parms)) parms))
(if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el (if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el

View file

@ -129,7 +129,7 @@ Linum mode is a buffer-local minor mode."
;; Note that nowadays, this actually doesn't show line ;; Note that nowadays, this actually doesn't show line
;; numbers in client frames at all, because we visit the ;; numbers in client frames at all, because we visit the
;; file before creating the client frame. See bug#35726. ;; 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))) (linum-mode 1)))
(defun linum-delete-overlays () (defun linum-delete-overlays ()

View file

@ -1390,7 +1390,7 @@ Interactively, with a prefix arg, FORCE is t."
(cl-labels (cl-labels
((visible-buffer-window () ((visible-buffer-window ()
(and (or (not (daemonp)) (and (or (not (daemonp))
(not (null (frame-parameter nil 'client)))) (not (eq (selected-frame) terminal-frame)))
(get-buffer-window (current-buffer)))) (get-buffer-window (current-buffer))))
(start-post-command () (start-post-command ()
(remove-hook 'post-command-hook #'start-post-command (remove-hook 'post-command-hook #'start-post-command

View file

@ -282,7 +282,7 @@ a list of frames to update."
(and (eq auto-resize-tab-bars 'grow-only) (and (eq auto-resize-tab-bars 'grow-only)
(> (frame-parameter frame 'tab-bar-lines) 1)) (> (frame-parameter frame 'tab-bar-lines) 1))
;; Don't enable tab-bar in daemon's initial frame. ;; 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 (set-frame-parameter frame 'tab-bar-lines
(tab-bar--tab-bar-lines-for-frame frame))))) (tab-bar--tab-bar-lines-for-frame frame)))))
;; Update `default-frame-alist' ;; Update `default-frame-alist'