os.texi 91.1 KB
Newer Older
Glenn Morris's avatar
Glenn Morris committed
1 2
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
3
@c Copyright (C) 1990-1995, 1998-1999, 2001-2012
Glenn Morris's avatar
Glenn Morris committed
4
@c   Free Software Foundation, Inc.
Glenn Morris's avatar
Glenn Morris committed
5
@c See the file elisp.texi for copying conditions.
6
@setfilename ../../info/os
Tom Tromey's avatar
Tom Tromey committed
7
@node System Interface, Packaging, Display, Top
Glenn Morris's avatar
Glenn Morris committed
8 9 10
@chapter Operating System Interface

  This chapter is about starting and getting out of Emacs, access to
Glenn Morris's avatar
Glenn Morris committed
11
values in the operating system environment, and terminal input, output.
Glenn Morris's avatar
Glenn Morris committed
12

13 14 15
  @xref{Building Emacs}, for related information.  @xref{Display}, for
additional operating system status information pertaining to the
terminal and the screen.
Glenn Morris's avatar
Glenn Morris committed
16 17 18 19 20 21

@menu
* Starting Up::         Customizing Emacs startup processing.
* Getting Out::         How exiting works (permanent or temporary).
* System Environment::  Distinguish the name and kind of system.
* User Identification:: Finding the name and user id of the user.
Glenn Morris's avatar
Glenn Morris committed
22
* Time of Day::         Getting the current time.
23
* Time Conversion::     Converting a time from numeric form to
24
                          calendrical data and vice versa.
Glenn Morris's avatar
Glenn Morris committed
25 26 27 28
* Time Parsing::        Converting a time from numeric form to text
                          and vice versa.
* Processor Run Time::  Getting the run time used by Emacs.
* Time Calculations::   Adding, subtracting, comparing times, etc.
Glenn Morris's avatar
Glenn Morris committed
29
* Timers::              Setting a timer to call a function at a certain time.
Glenn Morris's avatar
Glenn Morris committed
30 31 32 33 34
* Idle Timers::         Setting a timer to call a function when Emacs has
                          been idle for a certain length of time.
* Terminal Input::      Accessing and recording terminal input.
* Terminal Output::     Controlling and recording terminal output.
* Sound Output::        Playing sounds on the computer's speaker.
35
* X11 Keysyms::         Operating on key symbols for X Windows.
Glenn Morris's avatar
Glenn Morris committed
36 37
* Batch Mode::          Running Emacs without terminal interaction.
* Session Management::  Saving and restoring state with X Session Management.
38
* Notifications::       Desktop notifications.
39
* Dynamic Libraries::   On-demand loading of support libraries.
Glenn Morris's avatar
Glenn Morris committed
40 41 42 43 44 45 46 47 48 49
@end menu

@node Starting Up
@section Starting Up Emacs

  This section describes what Emacs does when it is started, and how you
can customize these actions.

@menu
* Startup Summary::         Sequence of actions Emacs performs at startup.
50
* Init File::               Details on reading the init file.
Glenn Morris's avatar
Glenn Morris committed
51 52 53 54 55 56 57 58 59 60 61
* Terminal-Specific::       How the terminal-specific Lisp file is read.
* Command-Line Arguments::  How command-line arguments are processed,
                              and how you can customize them.
@end menu

@node Startup Summary
@subsection Summary: Sequence of Actions at Startup
@cindex initialization of Emacs
@cindex startup of Emacs
@cindex @file{startup.el}

62
  When Emacs is started up, it performs the following operations
Glenn Morris's avatar
Glenn Morris committed
63
(see @code{normal-top-level} in @file{startup.el}):
Glenn Morris's avatar
Glenn Morris committed
64 65 66 67

@enumerate
@item
It adds subdirectories to @code{load-path}, by running the file named
68 69 70 71
@file{subdirs.el} in each directory in the list.  Normally, this file
adds the directory's subdirectories to the list, and those are scanned
in their turn.  The files @file{subdirs.el} are normally generated
automatically when Emacs is installed.
Glenn Morris's avatar
Glenn Morris committed
72

Glenn Morris's avatar
Glenn Morris committed
73 74 75 76 77 78 79 80 81
@item
It registers input methods by loading any @file{leim-list.el} file
found in the @code{load-path}.

@c It removes PWD from the environment if it is not accurate.
@c It abbreviates default-directory.

@c Now normal-top-level calls command-line.

82
@vindex before-init-time
Glenn Morris's avatar
Glenn Morris committed
83
@item
84
It sets the variable @code{before-init-time} to the value of
85
@code{current-time} (@pxref{Time of Day}).  It also sets
86 87
@code{after-init-time} to @code{nil}, which signals to Lisp programs
that Emacs is being initialized.
Glenn Morris's avatar
Glenn Morris committed
88

Glenn Morris's avatar
Glenn Morris committed
89 90 91 92 93 94 95 96
@c set-locale-environment
@item
It sets the language environment and the terminal coding system,
if requested by environment variables such as @code{LANG}.

@item
It does some basic parsing of the command-line arguments.

97 98
@vindex initial-window-system@r{, and startup}
@vindex window-system-initialization-alist
Glenn Morris's avatar
Glenn Morris committed
99
@item
Glenn Morris's avatar
Glenn Morris committed
100 101 102 103 104 105 106 107 108
If not running in batch mode, it initializes the window system that
the variable @code{initial-window-system} specifies (@pxref{Window
Systems, initial-window-system}).  The initialization function for
each supported window system is specified by
@code{window-system-initialization-alist}.  If the value
of @code{initial-window-system} is @var{windowsystem}, then the
appropriate initialization function is defined in the file
@file{term/@var{windowsystem}-win.el}.  This file should have been
compiled into the Emacs executable when it was built.
109 110

@item
Glenn Morris's avatar
Glenn Morris committed
111
It runs the normal hook @code{before-init-hook}.
Glenn Morris's avatar
Glenn Morris committed
112 113

@item
Glenn Morris's avatar
Glenn Morris committed
114 115
If appropriate, it creates a graphical frame.  This is not done if the
options @samp{--batch} or @samp{--daemon} were specified.
Glenn Morris's avatar
Glenn Morris committed
116 117

@item
Glenn Morris's avatar
Glenn Morris committed
118 119 120 121
It initializes the initial frame's faces, and sets up the menu bar
and tool bar if needed.  If graphical frames are supported, it sets up
the tool bar even if the current frame is not a graphical one, since a
graphical frame may be created later on.
Glenn Morris's avatar
Glenn Morris committed
122 123

@item
Glenn Morris's avatar
Glenn Morris committed
124 125 126 127 128 129 130 131
It use @code{custom-reevaluate-setting} to re-initialize the members
of the list @code{custom-delayed-init-variables}.  These are any
pre-loaded user options whose default value depends on the run-time,
rather than build-time, context.
@xref{Building Emacs, custom-initialize-delay}.

@c @item
@c It registers the colors available for tty frames.
132 133

@item
134 135
It loads the library @file{site-start}, if it exists.  This is not
done if the options @samp{-Q} or @samp{--no-site-file} were specified.
Glenn Morris's avatar
Glenn Morris committed
136 137 138
@cindex @file{site-start.el}

@item
139 140 141 142
It loads your init file (@pxref{Init File}).  This is not done if the
options @samp{-q}, @samp{-Q}, or @samp{--batch} were specified.  If
the @samp{-u} option was specified, Emacs looks for the init file in
that user's home directory instead.
Glenn Morris's avatar
Glenn Morris committed
143 144

@item
145 146 147
It loads the library @file{default}, if it exists.  This is not done
if @code{inhibit-default-init} is non-@code{nil}, nor if the options
@samp{-q}, @samp{-Q}, or @samp{--batch} were specified.
Glenn Morris's avatar
Glenn Morris committed
148 149
@cindex @file{default.el}

150 151
@item
It loads your abbrevs from the file specified by
152 153 154
@code{abbrev-file-name}, if that file exists and can be read
(@pxref{Abbrev Files, abbrev-file-name}).  This is not done if the
option @samp{--batch} was specified.
155

Chong Yidong's avatar
Chong Yidong committed
156 157 158 159 160
@item
If @code{package-enable-at-startup} is non-@code{nil}, it calls the
function @code{package-initialize} to activate any optional Emacs Lisp
package that has been installed.  @xref{Packaging Basics}.

161 162
@vindex after-init-time
@item
163 164 165 166
It sets the variable @code{after-init-time} to the value of
@code{current-time}.  This variable was set to @code{nil} earlier;
setting it to the current time signals that the initialization phase
is over, and, together with @code{before-init-time}, provides the
167 168
measurement of how long it took.

Glenn Morris's avatar
Glenn Morris committed
169 170 171 172
@item
It runs the normal hook @code{after-init-hook}.

@item
173 174 175
If the buffer @samp{*scratch*} exists and is still in Fundamental mode
(as it should be by default), it sets its major mode according to
@code{initial-major-mode}.
Glenn Morris's avatar
Glenn Morris committed
176 177

@item
178
If started on a text terminal, it loads the terminal-specific
179 180 181
Lisp library, which is specified by the variable
@code{term-file-prefix} (@pxref{Terminal-Specific}).  This is not done
in @code{--batch} mode, nor if @code{term-file-prefix} is @code{nil}.
Glenn Morris's avatar
Glenn Morris committed
182

Glenn Morris's avatar
Glenn Morris committed
183 184
@c Now command-line calls command-line-1.

Glenn Morris's avatar
Glenn Morris committed
185 186 187 188 189
@item
It displays the initial echo area message, unless you have suppressed
that with @code{inhibit-startup-echo-area-message}.

@item
Glenn Morris's avatar
Glenn Morris committed
190
It processes any command-line options that were not handled earlier.
Glenn Morris's avatar
Glenn Morris committed
191

Glenn Morris's avatar
Glenn Morris committed
192 193
@c This next one is back in command-line, but the remaining bits of
@c command-line-1 are not done if noninteractive.
194 195 196 197 198
@item
It now exits if the option @code{--batch} was specified.

@item
If @code{initial-buffer-choice} is a string, it visits the file with
Glenn Morris's avatar
Glenn Morris committed
199
that name.  If the @samp{*scratch*} buffer exists and is
200 201
empty, it inserts @code{initial-scratch-message} into that buffer.

Glenn Morris's avatar
Glenn Morris committed
202 203 204 205 206 207 208 209 210
@c To make things nice and confusing, the next three items can be
@c called from two places.  If displaying a startup screen, they are
@c called in command-line-1 before the startup screen is shown.
@c inhibit-startup-hooks is then set and window-setup-hook set to nil.
@c If not displaying a startup screen, they are are called in
@c normal-top-level.
@c FIXME?  So it seems they can be called before or after the
@c daemon/session restore step?

Glenn Morris's avatar
Glenn Morris committed
211 212 213 214 215 216 217 218 219 220 221
@item
It runs @code{emacs-startup-hook} and then @code{term-setup-hook}.

@item
It calls @code{frame-notice-user-settings}, which modifies the
parameters of the selected frame according to whatever the init files
specify.

@item
It runs @code{window-setup-hook}.  @xref{Window Systems}.

222
@item
223 224
It displays the @dfn{startup screen}, which is a special buffer that
contains information about copyleft and basic Emacs usage.  This is
Glenn Morris's avatar
Glenn Morris committed
225 226 227
not done if @code{inhibit-startup-screen} or @code{initial-buffer-choice}
are non-@code{nil}, or if the @samp{--no-splash} or @samp{-Q} command-line
options were specified.
228

Glenn Morris's avatar
Glenn Morris committed
229 230 231 232 233 234 235 236 237 238 239 240
@c End of command-line-1.

@c Back to command-line from command-line-1.

@c This is the point at which we actually exit in batch mode, but the
@c last few bits of command-line-1 are not done in batch mode.

@item
If the option @code{--daemon} was specified, it calls
@code{server-start} and detaches from the controlling terminal.
@xref{Emacs Server,,, emacs, The GNU Emacs Manual}.

241 242 243
@item
If started by the X session manager, it calls
@code{emacs-session-restore} passing it as argument the ID of the
244
previous session.  @xref{Session Management}.
Glenn Morris's avatar
Glenn Morris committed
245 246 247 248 249

@c End of command-line.

@c Back to normal-top-level from command-line.

Glenn Morris's avatar
Glenn Morris committed
250 251
@end enumerate

252 253 254
@noindent
The following options affect some aspects of the startup sequence.

255
@defopt inhibit-startup-screen
256 257 258
This variable, if non-@code{nil}, inhibits the startup screen.  In
that case, Emacs typically displays the @samp{*scratch*} buffer; but
see @code{initial-buffer-choice}, below.
Glenn Morris's avatar
Glenn Morris committed
259

260 261 262
Do not set this variable in the init file of a new user, or in a way
that affects more than one user, as that would prevent new users from
receiving information about copyleft and basic Emacs usage.
263

264 265
@vindex inhibit-startup-message
@vindex inhibit-splash-screen
266 267 268 269 270
@code{inhibit-startup-message} and @code{inhibit-splash-screen} are
aliases for this variable.
@end defopt

@defopt initial-buffer-choice
Glenn Morris's avatar
Glenn Morris committed
271 272 273
If non-@code{nil}, this variable is a string that specifies a file or
directory for Emacs to display after starting up, instead of the
startup screen.
274 275 276
@ignore
@c I do not think this should be mentioned.  AFAICS it is just a dodge
@c around inhibit-startup-screen not being settable on a site-wide basis.
277
If its value is @code{t}, Emacs displays the @samp{*scratch*} buffer.
278
@end ignore
Glenn Morris's avatar
Glenn Morris committed
279 280 281 282 283 284 285 286 287 288 289 290 291 292
@end defopt

@defopt inhibit-startup-echo-area-message
This variable controls the display of the startup echo area message.
You can suppress the startup echo area message by adding text with this
form to your init file:

@example
(setq inhibit-startup-echo-area-message
      "@var{your-login-name}")
@end example

Emacs explicitly checks for an expression as shown above in your init
file; your login name must appear in the expression as a Lisp string
293
constant.  You can also use the Custom interface.  Other methods of setting
Glenn Morris's avatar
Glenn Morris committed
294
@code{inhibit-startup-echo-area-message} to the same value do not
295 296 297 298
inhibit the startup message.  This way, you can easily inhibit the
message for yourself if you wish, but thoughtless copying of your init
file will not inhibit the message for someone else.
@end defopt
Glenn Morris's avatar
Glenn Morris committed
299

300 301 302 303
@defopt initial-scratch-message
This variable, if non-@code{nil}, should be a string, which is
inserted into the @samp{*scratch*} buffer when Emacs starts up.  If it
is @code{nil}, the @samp{*scratch*} buffer is empty.
Glenn Morris's avatar
Glenn Morris committed
304 305
@end defopt

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
@noindent
The following command-line options affect some aspects of the startup
sequence.  @xref{Initial Options,,, emacs, The GNU Emacs Manual}.

@table @code
@item --no-splash
Do not display a splash screen.

@item --batch
Run without an interactive terminal.  @xref{Batch Mode}.

@item --daemon
Do not initialize any display; just start a server in the background.

@item --no-init-file
@itemx -Q
Do not load either the init file, or the @file{default} library.

@item --no-site-file
Do not load the @file{site-start} library.

@item --quick
@itemx -Q
Equivalent to @samp{-q --no-site-file --no-splash}.
@c and --no-site-lisp, but let's not mention that here.
@end table


Glenn Morris's avatar
Glenn Morris committed
334
@node Init File
Chong Yidong's avatar
Chong Yidong committed
335
@subsection The Init File
Glenn Morris's avatar
Glenn Morris committed
336 337
@cindex init file
@cindex @file{.emacs}
Chong Yidong's avatar
Chong Yidong committed
338
@cindex @file{init.el}
Glenn Morris's avatar
Glenn Morris committed
339 340

  When you start Emacs, it normally attempts to load your @dfn{init
341 342
file}.  This is either a file named @file{.emacs} or @file{.emacs.el}
in your home directory, or a file named @file{init.el} in a
Glenn Morris's avatar
Glenn Morris committed
343 344 345
subdirectory named @file{.emacs.d} in your home directory.
@ignore
Whichever place you use, you can also compile the file (@pxref{Byte
346 347
Compilation}); then the actual file loaded will be @file{.emacs.elc}
or @file{init.elc}.
Glenn Morris's avatar
Glenn Morris committed
348
@end ignore
Glenn Morris's avatar
Glenn Morris committed
349 350 351 352 353 354 355 356 357 358 359 360 361 362

  The command-line switches @samp{-q}, @samp{-Q}, and @samp{-u}
control whether and where to find the init file; @samp{-q} (and the
stronger @samp{-Q}) says not to load an init file, while @samp{-u
@var{user}} says to load @var{user}'s init file instead of yours.
@xref{Entering Emacs,,, emacs, The GNU Emacs Manual}.  If neither
option is specified, Emacs uses the @code{LOGNAME} environment
variable, or the @code{USER} (most systems) or @code{USERNAME} (MS
systems) variable, to find your home directory and thus your init
file; this way, even if you have su'd, Emacs still loads your own init
file.  If those environment variables are absent, though, Emacs uses
your user-id to find your home directory.

@cindex default init file
Chong Yidong's avatar
Chong Yidong committed
363 364 365 366 367
  An Emacs installation may have a @dfn{default init file}, which is a
Lisp library named @file{default.el}.  Emacs finds this file through
the standard search path for libraries (@pxref{How Programs Do
Loading}).  The Emacs distribution does not come with this file; it is
intended for local customizations.  If the default init file exists,
Glenn Morris's avatar
Glenn Morris committed
368
it is loaded whenever you start Emacs.  But your own personal init
Glenn Morris's avatar
Glenn Morris committed
369 370
file, if any, is loaded first; if it sets @code{inhibit-default-init}
to a non-@code{nil} value, then Emacs does not subsequently load the
Glenn Morris's avatar
Glenn Morris committed
371 372 373
@file{default.el} file.  In batch mode, or if you specify @samp{-q}
(or @samp{-Q}), Emacs loads neither your personal init file nor
the default init file.
Glenn Morris's avatar
Glenn Morris committed
374 375 376 377 378

  Another file for site-customization is @file{site-start.el}.  Emacs
loads this @emph{before} the user's init file.  You can inhibit the
loading of this file with the option @samp{--no-site-file}.

379
@defopt site-run-file
Glenn Morris's avatar
Glenn Morris committed
380 381 382 383
This variable specifies the site-customization file to load before the
user's init file.  Its normal value is @code{"site-start"}.  The only
way you can change it with real effect is to do so before dumping
Emacs.
Glenn Morris's avatar
Glenn Morris committed
384
@c So why even mention it here.  I imagine it is almost never changed.
385
@end defopt
Glenn Morris's avatar
Glenn Morris committed
386 387 388 389 390 391

  @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.

@defopt inhibit-default-init
Glenn Morris's avatar
Glenn Morris committed
392 393
If this variable is non-@code{nil}, it prevents Emacs from loading the
default initialization library file.  The default value is @code{nil}.
Glenn Morris's avatar
Glenn Morris committed
394 395 396 397
@end defopt

@defvar before-init-hook
This normal hook is run, once, just before loading all the init files
Glenn Morris's avatar
Glenn Morris committed
398
(@file{site-start.el}, your init file, and @file{default.el}).
Glenn Morris's avatar
Glenn Morris committed
399 400 401 402 403
(The only way to change it with real effect is before dumping Emacs.)
@end defvar

@defvar after-init-hook
This normal hook is run, once, just after loading all the init files
Glenn Morris's avatar
Glenn Morris committed
404 405 406
(@file{site-start.el}, your init file, and @file{default.el}),
before loading the terminal-specific library (if started on a text
terminal) and processing the command-line action arguments.
Glenn Morris's avatar
Glenn Morris committed
407 408 409 410
@end defvar

@defvar emacs-startup-hook
This normal hook is run, once, just after handling the command line
Glenn Morris's avatar
Glenn Morris committed
411 412
arguments, just before @code{term-setup-hook}.  In batch mode, Emacs
does not run either of these hooks.
Glenn Morris's avatar
Glenn Morris committed
413 414 415 416 417 418 419 420 421 422
@end defvar

@defvar user-init-file
This variable holds the absolute file name of the user's init file.  If the
actual init file loaded is a compiled file, such as @file{.emacs.elc},
the value refers to the corresponding source file.
@end defvar

@defvar user-emacs-directory
This variable holds the name of the @file{.emacs.d} directory.  It is
Glenn Morris's avatar
Glenn Morris committed
423
@file{~/.emacs.d} on all platforms but MS-DOS.
Glenn Morris's avatar
Glenn Morris committed
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
@end defvar

@node Terminal-Specific
@subsection Terminal-Specific Initialization
@cindex terminal-specific initialization

  Each terminal type can have its own Lisp library that Emacs loads when
run on that type of terminal.  The library's name is constructed by
concatenating the value of the variable @code{term-file-prefix} and the
terminal type (specified by the environment variable @code{TERM}).
Normally, @code{term-file-prefix} has the value
@code{"term/"}; changing this is not recommended.  Emacs finds the file
in the normal manner, by searching the @code{load-path} directories, and
trying the @samp{.elc} and @samp{.el} suffixes.

@cindex Termcap
Chong Yidong's avatar
Chong Yidong committed
440 441 442 443 444
  The usual role of a terminal-specific library is to enable special
keys to send sequences that Emacs can recognize.  It may also need to
set or add to @code{input-decode-map} if the Termcap or Terminfo entry
does not specify all the terminal's function keys.  @xref{Terminal
Input}.
Glenn Morris's avatar
Glenn Morris committed
445

Glenn Morris's avatar
Glenn Morris committed
446
  When the name of the terminal type contains a hyphen or underscore, and no library
Glenn Morris's avatar
Glenn Morris committed
447
is found whose name is identical to the terminal's name, Emacs strips
Glenn Morris's avatar
Glenn Morris committed
448
from the terminal's name the last hyphen or underscore and everything that follows
Glenn Morris's avatar
Glenn Morris committed
449
it, and tries again.  This process is repeated until Emacs finds a
Glenn Morris's avatar
Glenn Morris committed
450 451
matching library, or until there are no more hyphens or underscores in the name
(i.e.@: there is no terminal-specific library).  For example, if the
Chong Yidong's avatar
Chong Yidong committed
452 453 454 455
terminal name is @samp{xterm-256color} and there is no
@file{term/xterm-256color.el} library, Emacs tries to load
@file{term/xterm.el}.  If necessary, the terminal library can evaluate
@code{(getenv "TERM")} to find the full name of the terminal type.
Glenn Morris's avatar
Glenn Morris committed
456 457 458 459 460 461 462 463

  Your init file can prevent the loading of the
terminal-specific library by setting the variable
@code{term-file-prefix} to @code{nil}.  This feature is useful when
experimenting with your own peculiar customizations.

  You can also arrange to override some of the actions of the
terminal-specific library by setting the variable
Glenn Morris's avatar
Glenn Morris committed
464
@code{term-setup-hook}.  This is a normal hook that Emacs runs
465
at the end of its initialization, after loading both
Glenn Morris's avatar
Glenn Morris committed
466 467
your init file and any terminal-specific libraries.  You could
use this hook to define initializations for terminals that do not
Glenn Morris's avatar
Glenn Morris committed
468 469 470 471
have their own libraries.  @xref{Hooks}.

@defvar term-file-prefix
@cindex @code{TERM} environment variable
Chong Yidong's avatar
Chong Yidong committed
472 473
If the value of this variable is non-@code{nil}, Emacs loads a
terminal-specific initialization file as follows:
Glenn Morris's avatar
Glenn Morris committed
474 475 476 477 478 479 480 481

@example
(load (concat term-file-prefix (getenv "TERM")))
@end example

@noindent
You may set the @code{term-file-prefix} variable to @code{nil} in your
init file if you do not wish to load the
Glenn Morris's avatar
Glenn Morris committed
482
terminal-initialization file.
Glenn Morris's avatar
Glenn Morris committed
483

Glenn Morris's avatar
Glenn Morris committed
484
On MS-DOS, Emacs sets the @code{TERM} environment variable to @samp{internal}.
Glenn Morris's avatar
Glenn Morris committed
485 486 487 488 489 490 491 492 493 494
@end defvar

@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.

You can use @code{term-setup-hook} to override the definitions made by a
terminal-specific file.

Glenn Morris's avatar
Glenn Morris committed
495 496
For a related feature, @pxref{Window Systems, window-setup-hook}.
@end defvar
Glenn Morris's avatar
Glenn Morris committed
497 498 499 500 501

@node Command-Line Arguments
@subsection Command-Line Arguments
@cindex command-line arguments

Chong Yidong's avatar
Chong Yidong committed
502
  You can use command-line arguments to request various actions when
Glenn Morris's avatar
Glenn Morris committed
503 504 505 506 507 508 509
you start Emacs.  Note that the recommended way of using Emacs is to
start it just once, after logging in, and then do all editing in the same
Emacs session (@pxref{Entering Emacs,,, emacs, The GNU Emacs Manual}).
For this reason, you might not use command-line arguments very often;
nonetheless, they can be useful when invoking Emacs from session
scripts or debugging Emacs.  This section describes how Emacs
processes command-line arguments.
Glenn Morris's avatar
Glenn Morris committed
510 511 512

@defun command-line
This function parses the command line that Emacs was called with,
Glenn Morris's avatar
Glenn Morris committed
513 514
processes it, and (amongst other things) loads the user's init file and
displays the startup messages.
Glenn Morris's avatar
Glenn Morris committed
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
@end defun

@defvar command-line-processed
The value of this variable is @code{t} once the command line has been
processed.

If you redump Emacs by calling @code{dump-emacs}, you may wish to set
this variable to @code{nil} first in order to cause the new dumped Emacs
to process its new command-line arguments.
@end defvar

@defvar command-switch-alist
@cindex switches on command line
@cindex options on command line
@cindex command-line options
Glenn Morris's avatar
Glenn Morris committed
530 531 532
This variable is an alist of user-defined command-line options and
associated handler functions.  By default it is empty, but you can
add elements if you wish.
Glenn Morris's avatar
Glenn Morris committed
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568

A @dfn{command-line option} is an argument on the command line, which
has the form:

@example
-@var{option}
@end example

The elements of the @code{command-switch-alist} look like this:

@example
(@var{option} . @var{handler-function})
@end example

The @sc{car}, @var{option}, is a string, the name of a command-line
option (not including the initial hyphen).  The @var{handler-function}
is called to handle @var{option}, and receives the option name as its
sole argument.

In some cases, the option is followed in the command line by an
argument.  In these cases, the @var{handler-function} can find all the
remaining command-line arguments in the variable
@code{command-line-args-left}.  (The entire list of command-line
arguments is in @code{command-line-args}.)

The command-line arguments are parsed by the @code{command-line-1}
function in the @file{startup.el} file.  See also @ref{Emacs
Invocation, , Command Line Arguments for Emacs Invocation, emacs, The
GNU Emacs Manual}.
@end defvar

@defvar command-line-args
The value of this variable is the list of command-line arguments passed
to Emacs.
@end defvar

569
@defvar command-line-args-left
570
@vindex argv
571
The value of this variable is the list of command-line arguments that
Glenn Morris's avatar
Glenn Morris committed
572 573 574
have not yet been processed.
@c Don't mention this, since it is a "bad name for a dynamically bound variable"
@c @code{argv} is an alias for this.
575 576
@end defvar

Glenn Morris's avatar
Glenn Morris committed
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
@defvar command-line-functions
This variable's value is a list of functions for handling an
unrecognized command-line argument.  Each time the next argument to be
processed has no special meaning, the functions in this list are called,
in order of appearance, until one of them returns a non-@code{nil}
value.

These functions are called with no arguments.  They can access the
command-line argument under consideration through the variable
@code{argi}, which is bound temporarily at this point.  The remaining
arguments (not including the current one) are in the variable
@code{command-line-args-left}.

When a function recognizes and processes the argument in @code{argi}, it
should return a non-@code{nil} value to say it has dealt with that
argument.  If it has also dealt with some of the following arguments, it
can indicate that by deleting them from @code{command-line-args-left}.

Glenn Morris's avatar
Glenn Morris committed
595
If all of these functions return @code{nil}, then the argument is treated
Glenn Morris's avatar
Glenn Morris committed
596 597 598 599 600 601 602 603 604
as a file name to visit.
@end defvar

@node Getting Out
@section Getting Out of Emacs
@cindex exiting Emacs

  There are two ways to get out of Emacs: you can kill the Emacs job,
which exits permanently, or you can suspend it, which permits you to
605 606 607
reenter the Emacs process later.  (In a graphical environment, you can
of course simply switch to another application without doing anything
special to Emacs, then switch back to Emacs when you want.)
Glenn Morris's avatar
Glenn Morris committed
608 609 610 611 612 613 614 615 616 617 618

@menu
* Killing Emacs::        Exiting Emacs irreversibly.
* Suspending Emacs::     Exiting Emacs reversibly.
@end menu

@node Killing Emacs
@comment  node-name,  next,  previous,  up
@subsection Killing Emacs
@cindex killing Emacs

619 620 621 622
  Killing Emacs means ending the execution of the Emacs process.
If you started Emacs from a terminal, the parent process normally
resumes control.  The low-level primitive for killing Emacs is
@code{kill-emacs}.
Glenn Morris's avatar
Glenn Morris committed
623

624
@deffn Command kill-emacs &optional exit-data
625 626
This command calls the hook @code{kill-emacs-hook}, then exits the
Emacs process and kills it.
Glenn Morris's avatar
Glenn Morris committed
627

628 629
If @var{exit-data} is an integer, that is used as the exit status of
the Emacs process.  (This is useful primarily in batch operation; see
Glenn Morris's avatar
Glenn Morris committed
630 631 632 633 634
@ref{Batch Mode}.)

If @var{exit-data} is a string, its contents are stuffed into the
terminal input buffer so that the shell (or whatever program next reads
input) can read them.
635
@end deffn
Glenn Morris's avatar
Glenn Morris committed
636

637 638 639 640 641 642 643 644 645 646 647
@cindex SIGTERM
@cindex SIGHUP
@cindex SIGINT
@cindex operating system signal
  The @code{kill-emacs} function is normally called via the
higher-level command @kbd{C-x C-c}
(@code{save-buffers-kill-terminal}).  @xref{Exiting,,, emacs, The GNU
Emacs Manual}.  It is also called automatically if Emacs receives a
@code{SIGTERM} or @code{SIGHUP} operating system signal (e.g. when the
controlling terminal is disconnected), or if it receives a
@code{SIGINT} signal while running in batch mode (@pxref{Batch Mode}).
Glenn Morris's avatar
Glenn Morris committed
648

649 650 651 652 653 654 655 656
@defvar kill-emacs-hook
This normal hook is run by @code{kill-emacs}, before it kills Emacs.

Because @code{kill-emacs} can be called in situations where user
interaction is impossible (e.g. when the terminal is disconnected),
functions on this hook should not attempt to interact with the user.
If you want to interact with the user when Emacs is shutting down, use
@code{kill-emacs-query-functions}, described below.
Glenn Morris's avatar
Glenn Morris committed
657 658
@end defvar

659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
  When Emacs is killed, all the information in the Emacs process,
aside from files that have been saved, is lost.  Because killing Emacs
inadvertently can lose a lot of work, the
@code{save-buffers-kill-terminal} command queries for confirmation if
you have buffers that need saving or subprocesses that are running.
It also runs the abnormal hook @code{kill-emacs-query-functions}:

@defvar kill-emacs-query-functions
When @code{save-buffers-kill-terminal} is killing Emacs, it calls the
functions in this hook, after asking the standard questions and before
calling @code{kill-emacs}.  The functions are called in order of
appearance, with no arguments.  Each function can ask for additional
confirmation from the user.  If any of them returns @code{nil},
@code{save-buffers-kill-emacs} does not kill Emacs, and does not run
the remaining functions in this hook.  Calling @code{kill-emacs}
directly does not run this hook.
Glenn Morris's avatar
Glenn Morris committed
675 676 677 678 679 680
@end defvar

@node Suspending Emacs
@subsection Suspending Emacs
@cindex suspending Emacs

681
  On text terminals, it is possible to @dfn{suspend Emacs}, which
682 683 684 685 686 687
means stopping Emacs temporarily and returning control to its superior
process, which is usually the shell.  This allows you to resume
editing later in the same Emacs process, with the same buffers, the
same kill ring, the same undo history, and so on.  To resume Emacs,
use the appropriate command in the parent shell---most likely
@code{fg}.
Glenn Morris's avatar
Glenn Morris committed
688

689 690 691
@cindex controlling terminal
  Suspending works only on a terminal device from which the Emacs
session was started.  We call that device the @dfn{controlling
692
terminal} of the session.  Suspending is not allowed if the
693 694 695 696 697 698 699 700 701 702 703
controlling terminal is a graphical terminal.  Suspending is usually
not relevant in graphical environments, since you can simply switch to
another application without doing anything special to Emacs.

@c FIXME?  Are there any systems Emacs still supports that do not
@c have SIGTSTP?
@cindex SIGTSTP
  Some operating systems (those without @code{SIGTSTP}, or MS-DOS) do
not support suspension of jobs; on these systems, ``suspension''
actually creates a new shell temporarily as a subprocess of Emacs.
Then you would exit the shell to return to Emacs.
Glenn Morris's avatar
Glenn Morris committed
704

705
@deffn Command suspend-emacs &optional string
Glenn Morris's avatar
Glenn Morris committed
706 707 708 709
This function stops Emacs and returns control to the superior process.
If and when the superior process resumes Emacs, @code{suspend-emacs}
returns @code{nil} to its caller in Lisp.

710 711
This function works only on the controlling terminal of the Emacs
session; to relinquish control of other tty devices, use
712
@code{suspend-tty} (see below).  If the Emacs session uses more than
713 714 715
one terminal, you must delete the frames on all the other terminals
before suspending Emacs, or this function signals an error.
@xref{Multiple Terminals}.
716

717
If @var{string} is non-@code{nil}, its characters are sent to Emacs's
718 719 720 721
superior shell, to be read as terminal input.
@c FIXME?  It seems to me that shell does echo STRING.
The characters in @var{string} are not echoed by the superior shell;
only the results appear.
Glenn Morris's avatar
Glenn Morris committed
722 723

Before suspending, @code{suspend-emacs} runs the normal hook
724 725 726
@code{suspend-hook}.  After the user resumes Emacs,
@code{suspend-emacs} runs the normal hook @code{suspend-resume-hook}.
@xref{Hooks}.
Glenn Morris's avatar
Glenn Morris committed
727 728

The next redisplay after resumption will redraw the entire screen,
729 730
unless the variable @code{no-redraw-on-reenter} is non-@code{nil}.
@xref{Refresh Screen}.
Glenn Morris's avatar
Glenn Morris committed
731

732
Here is an example of how you could use these hooks:
Glenn Morris's avatar
Glenn Morris committed
733 734 735 736

@smallexample
@group
(add-hook 'suspend-hook
737 738
          (lambda () (or (y-or-n-p "Really suspend? ")
                         (error "Suspend canceled"))))
Glenn Morris's avatar
Glenn Morris committed
739
@end group
740 741 742 743 744 745 746 747 748
(add-hook 'suspend-resume-hook (lambda () (message "Resumed!")
                                 (sit-for 2)))
@end smallexample
@c The sit-for prevents the ``nil'' that suspend-emacs returns
@c hiding the message.

Here is what you would see upon evaluating @code{(suspend-emacs "pwd")}:

@smallexample
Glenn Morris's avatar
Glenn Morris committed
749 750 751 752 753 754 755 756
@group
---------- Buffer: Minibuffer ----------
Really suspend? @kbd{y}
---------- Buffer: Minibuffer ----------
@end group

@group
---------- Parent Shell ----------
757 758
bash$ /home/username
bash$ fg
Glenn Morris's avatar
Glenn Morris committed
759 760 761 762 763 764 765
@end group

@group
---------- Echo Area ----------
Resumed!
@end group
@end smallexample
766 767 768 769

@c FIXME?  AFAICS, it is echoed.
Note that @samp{pwd} is not echoed after Emacs is suspended.  But it
is read and executed by the shell.
770
@end deffn
Glenn Morris's avatar
Glenn Morris committed
771 772 773 774 775 776 777 778 779 780

@defvar suspend-hook
This variable is a normal hook that Emacs runs before suspending.
@end defvar

@defvar suspend-resume-hook
This variable is a normal hook that Emacs runs on resuming
after a suspension.
@end defvar

781 782 783 784
@defun suspend-tty &optional tty
If @var{tty} specifies a terminal device used by Emacs, this function
relinquishes the device and restores it to its prior state.  Frames
that used the device continue to exist, but are not updated and Emacs
785 786 787 788 789 790
doesn't read input from them.  @var{tty} can be a terminal object, a
frame (meaning the terminal for that frame), or @code{nil} (meaning
the terminal for the selected frame).  @xref{Multiple Terminals}.

If @var{tty} is already suspended, this function does nothing.

791
@vindex suspend-tty-functions
792 793
This function runs the hook @code{suspend-tty-functions}, passing the
terminal object as an argument to each function.
794 795 796
@end defun

@defun resume-tty &optional tty
797
This function resumes the previously suspended terminal device
798 799
@var{tty}; where @var{tty} has the same possible values as it does
for @code{suspend-tty}.
800

801
@vindex resume-tty-functions
802
This function reopens the terminal device, re-initializes it, and
803
redraws it with that terminal's selected frame.  It then runs the
804 805
hook @code{resume-tty-functions}, passing the terminal object as an
argument to each function.
806 807

If the same device is already used by another Emacs terminal, this
808 809
function signals an error.  If @var{tty} is not suspended, this
function does nothing.
810 811
@end defun

812 813 814
@defun controlling-tty-p &optional tty
This function returns non-@code{nil} if @var{tty} is the
controlling terminal of the Emacs session; @var{tty} can be a
815 816
terminal object, a frame (meaning the terminal for that frame), or
@code{nil} (meaning the terminal for the selected frame).
817 818 819 820
@end defun

@deffn Command suspend-frame
This command @dfn{suspends} a frame.  For GUI frames, it calls
821 822 823 824
@code{iconify-frame} (@pxref{Visibility of Frames}); for frames on
text terminals, it calls either @code{suspend-emacs} or
@code{suspend-tty}, depending on whether the frame is displayed on the
controlling terminal device or not.
825 826
@end deffn

Glenn Morris's avatar
Glenn Morris committed
827 828 829 830 831 832 833 834 835 836
@node System Environment
@section Operating System Environment
@cindex operating system environment

  Emacs provides access to variables in the operating system environment
through various functions.  These variables include the name of the
system, the user's @acronym{UID}, and so on.

@defvar system-configuration
This variable holds the standard GNU configuration name for the
837 838 839
hardware/software configuration of your system, as a string.  For
example, a typical value for a 64-bit GNU/Linux system is
@samp{"x86_64-unknown-linux-gnu"}.
Glenn Morris's avatar
Glenn Morris committed
840 841 842 843 844
@end defvar

@cindex system type and name
@defvar system-type
The value of this variable is a symbol indicating the type of operating
845
system Emacs is running on.  The possible values are:
Glenn Morris's avatar
Glenn Morris committed
846

847
@table @code
848 849
@item aix
IBM's AIX.
Glenn Morris's avatar
Glenn Morris committed
850 851

@item berkeley-unix
852
Berkeley BSD and its variants.
Glenn Morris's avatar
Glenn Morris committed
853 854

@item cygwin
855 856 857 858
Cygwin, a Posix layer on top of MS-Windows.

@item darwin
Darwin (Mac OS X).
Glenn Morris's avatar
Glenn Morris committed
859 860

@item gnu
861
The GNU system (using the GNU kernel, which consists of the HURD and Mach).
Glenn Morris's avatar
Glenn Morris committed
862 863 864

@item gnu/linux
A GNU/Linux system---that is, a variant GNU system, using the Linux
865
kernel.  (These systems are the ones people often call ``Linux'', but
Glenn Morris's avatar
Glenn Morris committed
866 867
actually Linux is just the kernel, not the whole system.)

868 869 870
@item gnu/kfreebsd
A GNU (glibc-based) system with a FreeBSD kernel.

Glenn Morris's avatar
Glenn Morris committed
871 872 873 874 875 876 877
@item hpux
Hewlett-Packard HPUX operating system.

@item irix
Silicon Graphics Irix system.

@item ms-dos
878 879
Microsoft's DOS.  Emacs compiled with DJGPP for MS-DOS binds
@code{system-type} to @code{ms-dos} even when you run it on MS-Windows.
Glenn Morris's avatar
Glenn Morris committed
880 881

@item usg-unix-v
882
AT&T Unix System V.
Glenn Morris's avatar
Glenn Morris committed
883 884

@item windows-nt
885 886
Microsoft Windows NT, 9X and later.  The value of @code{system-type}
is always @code{windows-nt}, e.g. even on Windows 7.
Glenn Morris's avatar
Glenn Morris committed
887 888 889 890 891

@end table

We do not wish to add new symbols to make finer distinctions unless it
is absolutely necessary!  In fact, we hope to eliminate some of these
892 893 894
alternatives in the future.  If you need to make a finer distinction
than @code{system-type} allows for, you can test
@code{system-configuration}, e.g. against a regexp.
Glenn Morris's avatar
Glenn Morris committed
895 896 897
@end defvar

@defun system-name
898 899
This function returns the name of the machine you are running on, as a
string.
Glenn Morris's avatar
Glenn Morris committed
900 901 902 903 904 905 906 907 908
@end defun

  The symbol @code{system-name} is a variable as well as a function.  In
fact, the function returns whatever value the variable
@code{system-name} currently holds.  Thus, you can set the variable
@code{system-name} in case Emacs is confused about the name of your
system.  The variable is also useful for constructing frame titles
(@pxref{Frame Titles}).

909
@c FIXME seems like this section is not the best place for this option?
910
@defopt mail-host-address
Glenn Morris's avatar
Glenn Morris committed
911 912 913 914 915 916
If this variable is non-@code{nil}, it is used instead of
@code{system-name} for purposes of generating email addresses.  For
example, it is used when constructing the default value of
@code{user-mail-address}.  @xref{User Identification}.  (Since this is
done when Emacs starts up, the value actually used is the one saved when
Emacs was dumped.  @xref{Building Emacs}.)
917 918
@c FIXME sounds like should probably give this a :set-after and some
@c custom-initialize-delay voodoo.
919
@end defopt
Glenn Morris's avatar
Glenn Morris committed
920

921
@deffn Command getenv var &optional frame
Glenn Morris's avatar
Glenn Morris committed
922 923 924
@cindex environment variable access
This function returns the value of the environment variable @var{var},
as a string.  @var{var} should be a string.  If @var{var} is undefined
925 926 927
in the environment, @code{getenv} returns @code{nil}.  It returns
@samp{""} if @var{var} is set but null.  Within Emacs, a list of environment
variables and their values is kept in the variable @code{process-environment}.
Glenn Morris's avatar
Glenn Morris committed
928 929 930 931 932 933

@example
@group
(getenv "USER")
     @result{} "lewis"
@end group
934 935 936
@end example

The shell command @code{printenv} prints all or part of the environment:
Glenn Morris's avatar
Glenn Morris committed
937

938
@example
Glenn Morris's avatar
Glenn Morris committed
939
@group
940 941
bash$ printenv
PATH=/usr/local/bin:/usr/bin:/bin
Glenn Morris's avatar
Glenn Morris committed
942 943 944
USER=lewis
@end group
@group
945 946 947
TERM=xterm
SHELL=/bin/bash
HOME=/home/lewis
Glenn Morris's avatar
Glenn Morris committed
948
@end group
949
@dots{}
Glenn Morris's avatar
Glenn Morris committed
950 951 952
@end example
@end deffn

953
@deffn Command setenv variable &optional value substitute
Glenn Morris's avatar
Glenn Morris committed
954 955 956 957 958 959 960
This command sets the value of the environment variable named
@var{variable} to @var{value}.  @var{variable} should be a string.
Internally, Emacs Lisp can handle any string.  However, normally
@var{variable} should be a valid shell identifier, that is, a sequence
of letters, digits and underscores, starting with a letter or
underscore.  Otherwise, errors may occur if subprocesses of Emacs try
to access the value of @var{variable}.  If @var{value} is omitted or
961 962 963 964 965 966 967
@code{nil} (or, interactively, with a prefix argument), @code{setenv}
removes @var{variable} from the environment.  Otherwise, @var{value}
should be a string.

If the optional argument @var{substitute} is non-@code{nil}, Emacs
calls the function @code{substitute-env-vars} to expand any
environment variables in @var{value}.
Glenn Morris's avatar
Glenn Morris committed
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983

@code{setenv} works by modifying @code{process-environment}; binding
that variable with @code{let} is also reasonable practice.

@code{setenv} returns the new value of @var{variable}, or @code{nil}
if it removed @var{variable} from the environment.
@end deffn

@defvar process-environment
This variable is a list of strings, each describing one environment
variable.  The functions @code{getenv} and @code{setenv} work by means
of this variable.

@smallexample
@group
process-environment
984
@result{} ("PATH=/usr/local/bin:/usr/bin:/bin"
Glenn Morris's avatar
Glenn Morris committed
985 986 987
    "USER=lewis"
@end group
@group
988 989 990 991
    "TERM=xterm"
    "SHELL=/bin/bash"
    "HOME=/home/lewis"
    @dots{})
Glenn Morris's avatar
Glenn Morris committed
992 993 994 995 996 997 998 999
@end group
@end smallexample

If @code{process-environment} contains ``duplicate'' elements that
specify the same environment variable, the first of these elements
specifies the variable, and the other ``duplicates'' are ignored.
@end defvar

1000 1001
@defvar initial-environment
This variable holds the list of environment variables Emacs inherited
1002
from its parent process when Emacs started.
1003 1004
@end defvar

Glenn Morris's avatar
Glenn Morris committed
1005
@defvar path-separator
1006
This variable holds a string that says which character separates
Glenn Morris's avatar
Glenn Morris committed
1007
directories in a search path (as found in an environment variable).  Its
1008
value is @code{":"} for Unix and GNU systems, and @code{";"} for MS systems.
Glenn Morris's avatar
Glenn Morris committed
1009 1010 1011
@end defvar

@defun parse-colon-path path
1012
This function takes a search path string such as the value of
Glenn Morris's avatar
Glenn Morris committed
1013
the @code{PATH} environment variable, and splits it at the separators,
1014 1015 1016
returning a list of directory names.  @code{nil} in this list means
the current directory.  Although the function's name says
``colon'', it actually uses the value of @code{path-separator}.
Glenn Morris's avatar
Glenn Morris committed
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030

@example
(parse-colon-path ":/foo:/bar")
     @result{} (nil "/foo/" "/bar/")
@end example
@end defun

@defvar invocation-name
This variable holds the program name under which Emacs was invoked.  The
value is a string, and does not include a directory name.
@end defvar

@defvar invocation-directory
This variable holds the directory from which the Emacs executable was
1031
invoked, or @code{nil} if that directory cannot be determined.
Glenn Morris's avatar
Glenn Morris committed
1032 1033 1034 1035
@end defvar

@defvar installation-directory
If non-@code{nil}, this is a directory within which to look for the
1036 1037
@file{lib-src} and @file{etc} subdirectories.  In an installed Emacs,
it is normally @code{nil}.  It is non-@code{nil}
Glenn Morris's avatar
Glenn Morris committed
1038 1039
when Emacs can't find those directories in their standard installed
locations, but can find them in a directory related somehow to the one
1040
containing the Emacs executable (i.e., @code{invocation-directory}).
Glenn Morris's avatar
Glenn Morris committed
1041 1042 1043
@end defvar

@defun load-average &optional use-float
1044 1045 1046
This function returns the current 1-minute, 5-minute, and 15-minute
system load averages, in a list.  The load average indicates the
number of processes trying to run on the system.
Glenn Morris's avatar
Glenn Morris committed
1047 1048

By default, the values are integers that are 100 times the system load
1049 1050
averages, but if @var{use-float} is non-@code{nil}, then they are
returned as floating point numbers without multiplying by 100.
Glenn Morris's avatar
Glenn Morris committed
1051 1052 1053 1054 1055

If it is impossible to obtain the load average, this function signals
an error.  On some platforms, access to load averages requires
installing Emacs as setuid or setgid so that it can read kernel
information, and that usually isn't advisable.
1056
@c FIXME which platforms are these?  Are they still relevant?
Glenn Morris's avatar
Glenn Morris committed
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071

If the 1-minute load average is available, but the 5- or 15-minute
averages are not, this function returns a shortened list containing
the available averages.

@example
@group
(load-average)
     @result{} (169 48 36)
@end group
@group
(load-average t)
     @result{} (1.69 0.48 0.36)
@end group
@end example
1072 1073

The shell command @code{uptime} returns similar information.