aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-03-11 09:10:19 +0000
committerRichard M. Stallman2002-03-11 09:10:19 +0000
commitf8e7eebe8330226ab20d42b2337ee79b6b7273ea (patch)
treebab46c3349b2909263e30cb6fa2da4a1e91817f5
parent8a5782b5da0b1305734714b37ed8d6e4c6ac41f0 (diff)
downloademacs-f8e7eebe8330226ab20d42b2337ee79b6b7273ea.tar.gz
emacs-f8e7eebe8330226ab20d42b2337ee79b6b7273ea.zip
Clean up session manager node.
-rw-r--r--lispref/os.texi52
1 files changed, 26 insertions, 26 deletions
diff --git a/lispref/os.texi b/lispref/os.texi
index 476511a41b6..2e3bae972c3 100644
--- a/lispref/os.texi
+++ b/lispref/os.texi
@@ -2000,36 +2000,38 @@ This variable is non-@code{nil} when Emacs is running in batch mode.
2000 2000
2001@node Session Management 2001@node Session Management
2002@section Session Management 2002@section Session Management
2003@cindex session management 2003@cindex session manager
2004@cindex X session management protocol
2005 2004
2006X has defined the X Session Management Protocol to handle start and 2005Emacs supports the X Session Management Protocol for suspension and
2007restart of applications. There is one session manager who has the 2006restart of applications. In the X Window System, a program called the
2008responsibility to keep track of the applications that are running 2007@dfn{session manager} has the responsibility to keep track of the
2009when the window system shuts down, so the session manager later can 2008applications that are running. During shutdown, the session manager
2010restart them. 2009asks applications to save their state, and delays the actual shutdown
2010until they respond. An application can also cancel the shutdown.
2011 2011
2012Before the session manager shuts down the window system it informs 2012When the session manager restarts a suspended session, it directs
2013applications that they should save their state. When the applications 2013these applications to individually reload their saved state. It does
2014are restarted, the applications will restore their state. 2014this by specifying a special command-line argument that says what
2015saved session to restore. For Emacs, this argument is @samp{--smid
2016@var{session}}.
2015 2017
2016@defvar emacs-save-session-functions 2018@defvar emacs-save-session-functions
2017@tindex emacs-save-session-functions 2019@tindex emacs-save-session-functions
2018Emacs supports saving state by using a hook called 2020Emacs supports saving state by using a hook called
2019@code{emacs-save-session-functions}. Each function in this hook is 2021@code{emacs-save-session-functions}. Each function in this hook is
2020called when the session manager tells Emacs that the window system is 2022called when the session manager tells Emacs that the window system is
2021shutting down. The functions are called with the current buffer set to 2023shutting down. The functions are called with the current buffer set
2022a temporary buffer. Functions can use @code{insert} to add lisp code 2024to a temporary buffer. Each functions can use @code{insert} to add
2023to this buffer. The buffer will then be saved in a lisp file that is 2025Lisp code to this buffer. At the end, Emacs saves the buffer in a
2024loaded when Emacs is restarted. 2026file that Emacs will load in order to restart the saved session.
2025 2027
2026If a function in @code{emacs-save-session-functions} returns non-nil 2028If a function in @code{emacs-save-session-functions} returns
2027Emacs will inform the session manager that the window system shutdown 2029non-@code{nil}, Emacs tells the session manager to cancel the
2028shall be cancelled. 2030shutdown.
2029@end defvar 2031@end defvar
2030 2032
2031Here is an example that just inserts some text into *scratch* when Emacs 2033Here is an example that just inserts some text into *scratch* when
2032is restarted by the session manager. 2034Emacs is restarted by the session manager.
2033 2035
2034@example 2036@example
2035@group 2037@group
@@ -2038,11 +2040,9 @@ is restarted by the session manager.
2038 2040
2039@group 2041@group
2040(defun save-yourself-test () 2042(defun save-yourself-test ()
2041 (progn 2043 (insert "(save-excursion
2042 (insert 2044 (switch-to-buffer \"*scratch*\")
2043 "(save-excursion 2045 (insert \"I am restored\"))")
2044 (switch-to-buffer \"*scratch*\") 2046 nil)
2045 (insert \"I am restored\"))")
2046 @result{} nil))
2047@end group 2047@end group
2048@end example 2048@end example