aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-03-10 13:48:49 +0200
committerEli Zaretskii2018-03-10 13:48:49 +0200
commita8be860e17e2a737bda7a4c5075b71f0fb627a92 (patch)
tree3e972e54fd96c0f671778d56a304ab6352182c04
parentbbf53d99b57bd3d7fc0427d378df2efc6fa10e00 (diff)
downloademacs-a8be860e17e2a737bda7a4c5075b71f0fb627a92.tar.gz
emacs-a8be860e17e2a737bda7a4c5075b71f0fb627a92.zip
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.
-rw-r--r--doc/emacs/misc.texi2
-rw-r--r--doc/lispref/frames.texi6
-rw-r--r--doc/lispref/hooks.texi1
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/server.el9
5 files changed, 26 insertions, 1 deletions
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 60986347a71..68bd308983f 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -2529,7 +2529,7 @@ e.g., the daemon cannot use GUI features, so parameters such as frame
2529position, size, and decorations cannot be restored. For that reason, 2529position, size, and decorations cannot be restored. For that reason,
2530you may wish to delay restoring the desktop in daemon mode until the 2530you may wish to delay restoring the desktop in daemon mode until the
2531first client connects, by calling @code{desktop-read} in a hook 2531first client connects, by calling @code{desktop-read} in a hook
2532function that you add to @code{after-make-frame-functions} 2532function that you add to @code{server-after-make-frame-hook}
2533(@pxref{Creating Frames,,, elisp, The Emacs Lisp Reference Manual}). 2533(@pxref{Creating Frames,,, elisp, The Emacs Lisp Reference Manual}).
2534 2534
2535@node Recursive Edit 2535@node Recursive Edit
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 2f9bb398865..459f05cb1c9 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -181,6 +181,12 @@ the value of that parameter in the created frame to its value in the
181selected frame. 181selected frame.
182@end defvar 182@end defvar
183 183
184@defopt server-after-make-frame-hook
185A normal hook run when the Emacs server creates a client frame. When
186this hook is called, the created frame is the selected one.
187@xref{Emacs Server,,, emacs, The GNU Emacs Manual}.
188@end defopt
189
184 190
185@node Multiple Terminals 191@node Multiple Terminals
186@section Multiple Terminals 192@section Multiple Terminals
diff --git a/doc/lispref/hooks.texi b/doc/lispref/hooks.texi
index db4e413921f..e374d02defb 100644
--- a/doc/lispref/hooks.texi
+++ b/doc/lispref/hooks.texi
@@ -66,6 +66,7 @@ not exactly a hook, but does a similar job.
66 66
67@item after-make-frame-functions 67@item after-make-frame-functions
68@itemx before-make-frame-hook 68@itemx before-make-frame-hook
69@itemx server-after-make-frame-hook
69@xref{Creating Frames}. 70@xref{Creating Frames}.
70 71
71@c Not general enough? 72@c Not general enough?
diff --git a/etc/NEWS b/etc/NEWS
index 14926ba2e3b..8d69dc6b538 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -84,6 +84,15 @@ behavior where the tooltip text is also shown when the corresponding
84action does not apply. 84action does not apply.
85 85
86+++ 86+++
87** New hook 'server-after-make-frame-hook'.
88This hook is a convenient place to perform initializations in daemon
89mode which require GUI features to be available. One example is
90restoration of the previous session using the desktop.el package: put
91the call to 'desktop-read' in this hook, if you want the GUI settings
92to be restored, or if desktop.el needs to interact with you during
93restoration of the session.
94
95+++
87** New function 'logcount' calculates an integer's Hamming weight. 96** New function 'logcount' calculates an integer's Hamming weight.
88 97
89+++ 98+++
diff --git a/lisp/server.el b/lisp/server.el
index a892203c24a..ff03cbe622c 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -188,6 +188,13 @@ space (this means characters from ! to ~; or from code 33 to
188 :group 'server 188 :group 'server
189 :type 'hook) 189 :type 'hook)
190 190
191(defcustom server-after-make-frame-hook nil
192 "Hook run when the Emacs server creates a client frame.
193The created frame is selected when the hook is called."
194 :group 'server
195 :type 'hook
196 :version "27.1")
197
191(defcustom server-done-hook nil 198(defcustom server-done-hook nil
192 "Hook run when done editing a buffer for the Emacs server." 199 "Hook run when done editing a buffer for the Emacs server."
193 :group 'server 200 :group 'server
@@ -1336,9 +1343,11 @@ The following commands are accepted by the client:
1336 ((or isearch-mode (minibufferp)) 1343 ((or isearch-mode (minibufferp))
1337 nil) 1344 nil)
1338 ((and frame (null buffers)) 1345 ((and frame (null buffers))
1346 (run-hooks 'server-after-make-frame-hook)
1339 (message "%s" (substitute-command-keys 1347 (message "%s" (substitute-command-keys
1340 "When done with this frame, type \\[delete-frame]"))) 1348 "When done with this frame, type \\[delete-frame]")))
1341 ((not (null buffers)) 1349 ((not (null buffers))
1350 (run-hooks 'server-after-make-frame-hook)
1342 (server-switch-buffer (car buffers) nil (cdr (car files))) 1351 (server-switch-buffer (car buffers) nil (cdr (car files)))
1343 (run-hooks 'server-switch-hook) 1352 (run-hooks 'server-switch-hook)
1344 (unless nowait 1353 (unless nowait