Mercurial > emacs
comparison lispref/os.texi @ 43822:340b4384f4ac
(Session Management): New node about X Session management.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sun, 10 Mar 2002 16:31:30 +0000 |
parents | 2f863ec2724c |
children | 7e937c00ff00 |
comparison
equal
deleted
inserted
replaced
43821:f57c0d6e61c6 | 43822:340b4384f4ac |
---|---|
29 * Terminal Output:: Recording terminal output for debugging. | 29 * Terminal Output:: Recording terminal output for debugging. |
30 * Sound Output:: Playing sounds on the computer's speaker. | 30 * Sound Output:: Playing sounds on the computer's speaker. |
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 |
37 @section Starting Up Emacs | 38 @section Starting Up Emacs |
38 | 39 |
1994 generates, such as command echoing, is suppressed entirely.) | 1995 generates, such as command echoing, is suppressed entirely.) |
1995 | 1996 |
1996 @defvar noninteractive | 1997 @defvar noninteractive |
1997 This variable is non-@code{nil} when Emacs is running in batch mode. | 1998 This 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 | |
2006 X has defined the X Session Management Protocol to handle start and | |
2007 restart of applications. There is one session manager who has the | |
2008 responsibility to keep track of the applications that are running | |
2009 when the window system shuts down, so the session manager later can | |
2010 restart them. | |
2011 | |
2012 Before the session manager shuts down the window system it informs | |
2013 applications that they should save their state. When the applications | |
2014 are restarted, the applications will restore their state. | |
2015 | |
2016 @defvar emacs-save-session-functions | |
2017 @tindex emacs-save-session-functions | |
2018 Emacs supports saving state by using a hook called | |
2019 @code{emacs-save-session-functions}. Each function in this hook is | |
2020 called when the session manager tells Emacs that the window system is | |
2021 shutting down. The functions are called with the current buffer set to | |
2022 a temporary buffer. Functions can use @code{insert} to add lisp code | |
2023 to this buffer. The buffer will then be saved in a lisp file that is | |
2024 loaded when Emacs is restarted. | |
2025 | |
2026 If a function in @code{emacs-save-session-functions} returns non-nil | |
2027 Emacs will inform the session manager that the window system shutdown | |
2028 shall be cancelled. | |
2029 @end defvar | |
2030 | |
2031 Here is an example that just inserts some text into *scratch* when Emacs | |
2032 is 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 |