aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Djärv2002-03-10 16:31:30 +0000
committerJan Djärv2002-03-10 16:31:30 +0000
commit750c3b025db5cde7bbebc451dc76e37026c6f364 (patch)
treef89fb6e06df65ac74224e98ab6ed4f4dd9e33597
parentca57f55d6f96265d73b4dfadcc82fc58c934e6be (diff)
downloademacs-750c3b025db5cde7bbebc451dc76e37026c6f364.tar.gz
emacs-750c3b025db5cde7bbebc451dc76e37026c6f364.zip
(Session Management): New node about X Session management.
-rw-r--r--lispref/os.texi50
1 files changed, 50 insertions, 0 deletions
diff --git a/lispref/os.texi b/lispref/os.texi
index d035f58d396..476511a41b6 100644
--- a/lispref/os.texi
+++ b/lispref/os.texi
@@ -31,6 +31,7 @@ pertaining to the terminal and the screen.
31* Special Keysyms:: Defining system-specific key symbols for X. 31* Special Keysyms:: Defining system-specific key symbols for X.
32* Flow Control:: How to turn output flow control on or off. 32* Flow Control:: How to turn output flow control on or off.
33* Batch Mode:: Running Emacs without terminal interaction. 33* Batch Mode:: Running Emacs without terminal interaction.
34* Session Management:: Saving and restoring state with X Session Management.
34@end menu 35@end menu
35 36
36@node Starting Up 37@node Starting Up
@@ -1996,3 +1997,52 @@ generates, such as command echoing, is suppressed entirely.)
1996@defvar noninteractive 1997@defvar noninteractive
1997This variable is non-@code{nil} when Emacs is running in batch mode. 1998This variable is non-@code{nil} when Emacs is running in batch mode.
1998@end defvar 1999@end defvar
2000
2001@node Session Management
2002@section Session Management
2003@cindex session management
2004@cindex X session management protocol
2005
2006X has defined the X Session Management Protocol to handle start and
2007restart of applications. There is one session manager who has the
2008responsibility to keep track of the applications that are running
2009when the window system shuts down, so the session manager later can
2010restart them.
2011
2012Before the session manager shuts down the window system it informs
2013applications that they should save their state. When the applications
2014are restarted, the applications will restore their state.
2015
2016@defvar emacs-save-session-functions
2017@tindex emacs-save-session-functions
2018Emacs supports saving state by using a hook called
2019@code{emacs-save-session-functions}. Each function in this hook is
2020called when the session manager tells Emacs that the window system is
2021shutting down. The functions are called with the current buffer set to
2022a temporary buffer. Functions can use @code{insert} to add lisp code
2023to this buffer. The buffer will then be saved in a lisp file that is
2024loaded when Emacs is restarted.
2025
2026If a function in @code{emacs-save-session-functions} returns non-nil
2027Emacs will inform the session manager that the window system shutdown
2028shall be cancelled.
2029@end defvar
2030
2031Here is an example that just inserts some text into *scratch* when Emacs
2032is restarted by the session manager.
2033
2034@example
2035@group
2036(add-hook 'emacs-save-session-functions 'save-yourself-test)
2037@end group
2038
2039@group
2040(defun save-yourself-test ()
2041 (progn
2042 (insert
2043 "(save-excursion
2044 (switch-to-buffer \"*scratch*\")
2045 (insert \"I am restored\"))")
2046 @result{} nil))
2047@end group
2048@end example