diff options
| author | Jan Djärv | 2002-03-10 16:31:30 +0000 |
|---|---|---|
| committer | Jan Djärv | 2002-03-10 16:31:30 +0000 |
| commit | 750c3b025db5cde7bbebc451dc76e37026c6f364 (patch) | |
| tree | f89fb6e06df65ac74224e98ab6ed4f4dd9e33597 | |
| parent | ca57f55d6f96265d73b4dfadcc82fc58c934e6be (diff) | |
| download | emacs-750c3b025db5cde7bbebc451dc76e37026c6f364.tar.gz emacs-750c3b025db5cde7bbebc451dc76e37026c6f364.zip | |
(Session Management): New node about X Session management.
| -rw-r--r-- | lispref/os.texi | 50 |
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 |
| 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 | ||