/[emacs]/emacs/lispref/os.texi
ViewVC logotype

Diff of /emacs/lispref/os.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.46 by rms, Fri Feb 1 04:28:28 2002 UTC revision 1.47 by jhd, Sun Mar 10 16:31:30 2002 UTC
# Line 31  pertaining to the terminal and the scree Line 31  pertaining to the terminal and the scree
31  * Special Keysyms::     Defining system-specific key symbols for X.  * Special Keysyms::     Defining system-specific key symbols for X.
32  * Flow Control::        How to turn output flow control on or off.  * Flow Control::        How to turn output flow control on or off.
33  * Batch Mode::          Running Emacs without terminal interaction.  * Batch Mode::          Running Emacs without terminal interaction.
34    * Session Management::  Saving and restoring state with X Session Management.
35  @end menu  @end menu
36    
37  @node Starting Up  @node Starting Up
# Line 1996  generates, such as command echoing, is s Line 1997  generates, such as command echoing, is s
1997  @defvar noninteractive  @defvar noninteractive
1998  This variable is non-@code{nil} when Emacs is running in batch mode.  This variable is non-@code{nil} when Emacs is running in batch mode.
1999  @end defvar  @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

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26