@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
-@c Free Software Foundation, Inc.
+@c Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/os
@node System Interface, Antinews, Calendar, Top
* Terminal Input:: Recording terminal input for debugging.
* Terminal Output:: Recording terminal output for debugging.
* Sound Output:: Playing sounds on the computer's speaker.
-* Special Keysyms:: Defining system-specific key symbols for X.
+* X11 Keysyms:: Operating on key symbols for X Windows
* Flow Control:: How to turn output flow control on or off.
* Batch Mode:: Running Emacs without terminal interaction.
+* Session Management:: Saving and restoring state with X Session Management.
@end menu
@node Starting Up
@file{site-start.el}.
@cindex @file{site-start.el}
-@item
+@item
It loads your init file (usually @file{~/.emacs}), unless @samp{-q},
@samp{-no-init-file}, or @samp{-batch} was specified on the command line.
The @samp{-u} option can specify another user whose home directory
should be used instead of @file{~}.
-@item
+@item
It loads the library @file{default}, unless @code{inhibit-default-init}
is non-@code{nil}. (This is not done in @samp{-batch} mode or if
@samp{-q} was specified on the command line.) The library's file name
the buffer @samp{*scratch*} is still current and still in Fundamental
mode.
-@item
+@item
It loads the terminal-specific Lisp file, if any, except when in batch
mode or using a window system.
It displays the initial echo area message, unless you have suppressed
that with @code{inhibit-startup-echo-area-message}.
-@item
+@item
It processes the action arguments from the command line.
-@item
+@item
It runs @code{emacs-startup-hook} and then @code{term-setup-hook}.
@item
parameters of the selected frame according to whatever the init files
specify.
-@item
+@item
It runs @code{window-setup-hook}. @xref{Window Systems}.
-@item
+@item
It displays copyleft, nonwarranty, and basic use information, provided
there were no remaining command-line arguments (a few steps above),
the value of @code{inhibit-startup-message} is @code{nil}, and the
Emacs.
@end defvar
- @xref{Init File Examples,,, emacs, The GNU Emacs Manual}, for
+ @xref{Init Examples,, Init File Examples, emacs, The GNU Emacs Manual}, for
examples of how to make various commonly desired customizations in your
@file{.emacs} file.
uses @samp{internal} as the terminal type.
@end defvar
-@defvar term-setup-hook
+@defvar term-setup-hook
This variable is a normal hook that Emacs runs after loading your
init file, the default initialization file (if any) and the
terminal-specific Lisp file.
-@var{option}
@end example
-The elements of the @code{command-switch-alist} look like this:
+The elements of the @code{command-switch-alist} look like this:
@example
(@var{option} . @var{handler-function})
The command-line arguments are parsed by the @code{command-line-1}
function in the @file{startup.el} file. See also @ref{Command
-Switches, , Command Line Switches and Arguments, emacs, The GNU Emacs
-Manual}.
+Arguments, , Command Line Arguments, emacs, The GNU Emacs Manual}.
@end defvar
@defvar command-line-args
@defvar kill-emacs-hook
This variable is a normal hook; once @code{save-buffers-kill-emacs} is
finished with all file saving and confirmation, it runs the functions in
-this hook.
+this hook. This hook is not run in batch mode.
@end defvar
@node Suspending Emacs
@item berkeley-unix
Berkeley BSD.
+@item cygwin
+Cygwin.
+
@item dgux
Data General DGUX operating system.
process-environment
@result{} ("l=/usr/stanford/lib/gnuemacs/lisp"
"PATH=.:/user/lewis/bin:/usr/class:/nfsusr/local/bin"
- "USER=lewis"
+ "USER=lewis"
@end group
@group
- "TERM=ibmapa16"
+ "TERM=ibmapa16"
"SHELL=/bin/csh"
"HOME=/user/lewis")
@end group
@defun user-real-uid
This function returns the real @sc{uid} of the user.
+The value may be a floating point number.
@example
@group
@end defun
@defun user-uid
-This function returns the effective @sc{uid} of the user.
+This function returns the effective @sc{uid} of the user.
+The value may be a floating point number.
@end defun
@node Time of Day
@section Timers for Delayed Execution
@cindex timer
- You can set up a @dfn{timer} to call a function at a specified future time or
-after a certain length of idleness.
+ You can set up a @dfn{timer} to call a function at a specified
+future time or after a certain length of idleness.
Emacs cannot run timers at any arbitrary point in a Lisp program; it
can run them only when Emacs could accept output from a subprocess:
timer's execution may be delayed if Emacs is busy. However, the time of
execution is very precise if Emacs is idle.
+ Emacs binds @code{inhibit-quit} to @code{t} before calling the timer
+function, because quitting out of many timer functions can leave
+things in an inconsistent state. This is normally unproblematical
+because most timer functions don't do a lot of work. Indeed, for a
+timer to calls a function that takes substantial time to run is likely
+to be annoying.
+
@defun run-at-time time repeat function &rest args
This function arranges to call @var{function} with arguments @var{args}
at time @var{time}. The argument @var{function} is a function to call
is called with one argument, a property list that describes the sound.
@end defvar
-@node Special Keysyms
-@section System-Specific X11 Keysyms
+@node X11 Keysyms
+@section Operating on X11 Keysyms
To define system-specific X11 keysyms, set the variable
@code{system-key-alist}.
This variable's value should be an alist with one element for each
system-specific keysym. Each element has the form @code{(@var{code}
. @var{symbol})}, where @var{code} is the numeric keysym code (not
-including the ``vendor specific'' bit,
+including the ``vendor specific'' bit,
@ifnottex
-2**28),
@end ifnottex
-@tex
+@tex
$-2^{28}$),
@end tex
and @var{symbol} is the name for the function key.
@ifnottex
-2**28
@end ifnottex
-@tex
+@tex
$-2^{28}$
@end tex
+ 168.
buffer-local. @xref{Multiple Displays}.
@end defvar
+You can specify which keysyms Emacs should use for the Meta, Alt, Hyper, and Super modifiers by setting these variables:
+
+@defvar x-alt-keysym
+@defvarx x-meta-keysym
+@defvarx x-hyper-keysym
+@defvarx x-super-keysym
+The name of the keysym that should stand for the Alt modifier
+(respectively, for Meta, Hyper, and Super). For example, here is
+how to swap the Meta and Alt modifiers within Emacs:
+@lisp
+(setq x-alt-keysym 'meta)
+(setq x-meta-keysym 'alt)
+@end lisp
+@end defvar
+
@node Flow Control
@section Flow Control
@cindex flow control characters
@defvar noninteractive
This variable is non-@code{nil} when Emacs is running in batch mode.
@end defvar
+
+@node Session Management
+@section Session Management
+@cindex session manager
+
+Emacs supports the X Session Management Protocol for suspension and
+restart of applications. In the X Window System, a program called the
+@dfn{session manager} has the responsibility to keep track of the
+applications that are running. During shutdown, the session manager
+asks applications to save their state, and delays the actual shutdown
+until they respond. An application can also cancel the shutdown.
+
+When the session manager restarts a suspended session, it directs
+these applications to individually reload their saved state. It does
+this by specifying a special command-line argument that says what
+saved session to restore. For Emacs, this argument is @samp{--smid
+@var{session}}.
+
+@defvar emacs-save-session-functions
+@tindex emacs-save-session-functions
+Emacs supports saving state by using a hook called
+@code{emacs-save-session-functions}. Each function in this hook is
+called when the session manager tells Emacs that the window system is
+shutting down. The functions are called with the current buffer set
+to a temporary buffer. Each functions can use @code{insert} to add
+Lisp code to this buffer. At the end, Emacs saves the buffer in a
+file that Emacs will load in order to restart the saved session.
+
+If a function in @code{emacs-save-session-functions} returns
+non-@code{nil}, Emacs tells the session manager to cancel the
+shutdown.
+@end defvar
+
+Here is an example that just inserts some text into *scratch* when
+Emacs is restarted by the session manager.
+
+@example
+@group
+(add-hook 'emacs-save-session-functions 'save-yourself-test)
+@end group
+
+@group
+(defun save-yourself-test ()
+ (insert "(save-excursion
+ (switch-to-buffer \"*scratch*\")
+ (insert \"I am restored\"))")
+ nil)
+@end group
+@end example