Commit a8be860e authored by Eli Zaretskii's avatar Eli Zaretskii

Improve support for desktop restoration in daemon mode

* lisp/server.el (server-after-make-frame-hook): New hook.
(server-execute): Call it after creating a new frame or before
switching to a buffer shown in a client frame.  (Bug#30421)

* doc/emacs/misc.texi (Saving Emacs Sessions): Adjust advice for
restoring desktop in daemon mode to the new hook.
* doc/lispref/frames.texi (Creating Frames, Standard Hooks):
Document server-after-make-frame-hook.

* etc/NEWS: Mention server-after-make-frame-hook.
parent bbf53d99
......@@ -2529,7 +2529,7 @@ e.g., the daemon cannot use GUI features, so parameters such as frame
position, size, and decorations cannot be restored. For that reason,
you may wish to delay restoring the desktop in daemon mode until the
first client connects, by calling @code{desktop-read} in a hook
function that you add to @code{after-make-frame-functions}
function that you add to @code{server-after-make-frame-hook}
(@pxref{Creating Frames,,, elisp, The Emacs Lisp Reference Manual}).
@node Recursive Edit
......
......@@ -181,6 +181,12 @@ the value of that parameter in the created frame to its value in the
selected frame.
@end defvar
@defopt server-after-make-frame-hook
A normal hook run when the Emacs server creates a client frame. When
this hook is called, the created frame is the selected one.
@xref{Emacs Server,,, emacs, The GNU Emacs Manual}.
@end defopt
@node Multiple Terminals
@section Multiple Terminals
......
......@@ -66,6 +66,7 @@ not exactly a hook, but does a similar job.
@item after-make-frame-functions
@itemx before-make-frame-hook
@itemx server-after-make-frame-hook
@xref{Creating Frames}.
@c Not general enough?
......
......@@ -83,6 +83,15 @@ Customize the option 'mode-line-default-help-echo' to restore the old
behavior where the tooltip text is also shown when the corresponding
action does not apply.
+++
** New hook 'server-after-make-frame-hook'.
This hook is a convenient place to perform initializations in daemon
mode which require GUI features to be available. One example is
restoration of the previous session using the desktop.el package: put
the call to 'desktop-read' in this hook, if you want the GUI settings
to be restored, or if desktop.el needs to interact with you during
restoration of the session.
+++
** New function 'logcount' calculates an integer's Hamming weight.
......
......@@ -188,6 +188,13 @@ space (this means characters from ! to ~; or from code 33 to
:group 'server
:type 'hook)
(defcustom server-after-make-frame-hook nil
"Hook run when the Emacs server creates a client frame.
The created frame is selected when the hook is called."
:group 'server
:type 'hook
:version "27.1")
(defcustom server-done-hook nil
"Hook run when done editing a buffer for the Emacs server."
:group 'server
......@@ -1336,9 +1343,11 @@ The following commands are accepted by the client:
((or isearch-mode (minibufferp))
nil)
((and frame (null buffers))
(run-hooks 'server-after-make-frame-hook)
(message "%s" (substitute-command-keys
"When done with this frame, type \\[delete-frame]")))
((not (null buffers))
(run-hooks 'server-after-make-frame-hook)
(server-switch-buffer (car buffers) nil (cdr (car files)))
(run-hooks 'server-switch-hook)
(unless nowait
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment