Merge branch 'master' into comment-cache
[emacs.git] / doc / emacs / cmdargs.texi
blob6c86670824505027be05021a594e6307f8074ffb
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2017 Free Software
3 @c Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Emacs Invocation
6 @appendix Command Line Arguments for Emacs Invocation
7 @cindex command line arguments
8 @cindex arguments (command line)
9 @cindex options (command line)
10 @cindex switches (command line)
11 @cindex startup (command line arguments)
12 @cindex invocation (command line arguments)
13 @c FIXME: Document '--smid'?  --xfq
15   Emacs supports command line arguments to request various actions
16 when invoking Emacs.  These are for compatibility with other editors
17 and for sophisticated activities.  We don't recommend using them for
18 ordinary editing (@xref{Emacs Server}, for a way to access an existing
19 Emacs job from the command line).
21   Arguments starting with @samp{-} are @dfn{options}, and so is
22 @samp{+@var{linenum}}.  All other arguments specify files to visit.
23 Emacs visits the specified files while it starts up.  The last file
24 specified on the command line becomes the current buffer; the other
25 files are also visited in other buffers.  As with most programs, the
26 special argument @samp{--} says that all subsequent arguments are file
27 names, not options, even if they start with @samp{-}.
29   Emacs command options can specify many things, such as the size and
30 position of the X window Emacs uses, its colors, and so on.  A few
31 options support advanced usage, such as running Lisp functions on files
32 in batch mode.  The sections of this chapter describe the available
33 options, arranged according to their purpose.
35   There are two ways of writing options: the short forms that start with
36 a single @samp{-}, and the long forms that start with @samp{--}.  For
37 example, @samp{-d} is a short form and @samp{--display} is the
38 corresponding long form.
40   The long forms with @samp{--} are easier to remember, but longer to
41 type.  However, you don't have to spell out the whole option name; any
42 unambiguous abbreviation is enough.  When a long option takes an
43 argument, you can use either a space or an equal sign to separate the
44 option name and the argument.  Thus, you can write either
45 @samp{--display sugar-bombs:0.0} or @samp{--display=sugar-bombs:0.0}.
46 We recommend an equal sign because it makes the relationship clearer,
47 and the tables below always show an equal sign.
49 @cindex initial options (command line)
50 @cindex action options (command line)
51 @vindex command-line-args
52   Most options specify how to initialize Emacs, or set parameters for
53 the Emacs session.  We call them @dfn{initial options}.  A few options
54 specify things to do, such as loading libraries or calling Lisp
55 functions.  These are called @dfn{action options}.  These and file
56 names together are called @dfn{action arguments}.  The action
57 arguments are stored as a list of strings in the variable
58 @code{command-line-args}.  (Actually, when Emacs starts up,
59 @code{command-line-args} contains all the arguments passed from the
60 command line; during initialization, the initial arguments are removed
61 from this list when they are processed, leaving only the action
62 arguments.)
64 @menu
65 * Action Arguments::    Arguments to visit files, load libraries,
66                           and call functions.
67 * Initial Options::     Arguments that take effect while starting Emacs.
68 * Command Example::     Examples of using command line arguments.
69 * Environment::         Environment variables that Emacs uses.
70 * Display X::           Changing the default display and using remote login.
71 * Font X::              Choosing a font for text, under X.
72 * Colors X::            Choosing display colors.
73 * Window Size X::       Start-up window size, under X.
74 * Borders X::           Internal and external borders, under X.
75 * Title X::             Specifying the initial frame's title.
76 * Icons X::             Choosing what sort of icon to use, under X.
77 * Misc X::              Other display options.
78 @end menu
80 @node Action Arguments
81 @appendixsec Action Arguments
83   Here is a table of action arguments:
85 @table @samp
86 @item @var{file}
87 @opindex --file
88 @itemx --file=@var{file}
89 @opindex --find-file
90 @itemx --find-file=@var{file}
91 @opindex --visit
92 @itemx --visit=@var{file}
93 @cindex visiting files, command-line argument
94 @vindex inhibit-startup-buffer-menu
95 Visit @var{file} using @code{find-file}.  @xref{Visiting}.
97 When Emacs starts up, it displays the startup buffer in one window,
98 and the buffer visiting @var{file} in another window
99 (@pxref{Windows}).  If you supply more than one file argument, the
100 displayed file is the last one specified on the command line; the
101 other files are visited but their buffers are not shown.
103 If the startup buffer is disabled (@pxref{Entering Emacs}), then
104 @var{file} is visited in a single window if one file argument was
105 supplied; with two file arguments, Emacs displays the files in two
106 different windows; with more than two file argument, Emacs displays
107 the last file specified in one window, plus a Buffer Menu in a
108 different window (@pxref{Several Buffers}).  To inhibit using the
109 Buffer Menu for this, change the variable
110 @code{inhibit-startup-buffer-menu} to @code{t}.
112 @item +@var{linenum} @var{file}
113 @opindex +@var{linenum}
114 Visit @var{file} using @code{find-file}, then go to line number
115 @var{linenum} in it.
117 @item +@var{linenum}:@var{columnnum} @var{file}
118 Visit @var{file} using @code{find-file}, then go to line number
119 @var{linenum} and put point at column number @var{columnnum}.
121 @item -l @var{file}
122 @opindex -l
123 @itemx --load=@var{file}
124 @opindex --load
125 @cindex loading Lisp libraries, command-line argument
126 Load a Lisp library named @var{file} with the function @code{load}.
127 If @var{file} is not an absolute file name, Emacs first looks for it
128 in the current directory, then in the directories listed in
129 @code{load-path} (@pxref{Lisp Libraries}).
131 @strong{Warning:} If previous command-line arguments have visited
132 files, the current directory is the directory of the last file
133 visited.
135 @item -L @var{dir}
136 @opindex -L
137 @itemx --directory=@var{dir}
138 @opindex --directory
139 Prepend directory @var{dir} to the variable @code{load-path}.
140 If you specify multiple @samp{-L} options, Emacs preserves the
141 relative order; i.e., using @samp{-L /foo -L /bar} results in
142 a @code{load-path} of the form @code{("/foo" "/bar" @dots{})}.
143 If @var{dir} begins with @samp{:}, Emacs removes the @samp{:} and
144 appends (rather than prepends) the remainder to @code{load-path}.
145 (On MS Windows, use @samp{;} instead of @samp{:}; i.e., use
146 the value of @code{path-separator}.)
148 @item -f @var{function}
149 @opindex -f
150 @itemx --funcall=@var{function}
151 @opindex --funcall
152 @cindex call Lisp functions, command-line argument
153 Call Lisp function @var{function}.  If it is an interactive function
154 (a command), it reads the arguments interactively just as if you had
155 called the same function with a key sequence.  Otherwise, it calls the
156 function with no arguments.
158 @item --eval=@var{expression}
159 @opindex --eval
160 @itemx --execute=@var{expression}
161 @opindex --execute
162 @cindex evaluate expression, command-line argument
163 Evaluate Lisp expression @var{expression}.
165 @item --insert=@var{file}
166 @opindex --insert
167 @cindex insert file contents, command-line argument
168 Insert the contents of @var{file} into the buffer that is current when
169 this command-line argument is processed.  Usually, this is the
170 @file{*scratch*} buffer (@pxref{Lisp Interaction}), but if arguments
171 earlier on the command line visit files or switch buffers, that might
172 be a different buffer.  The effect of this command-line argument is
173 like what @kbd{M-x insert-file} does (@pxref{Misc File Ops}).
175 @item --kill
176 @opindex --kill
177 Exit from Emacs without asking for confirmation.
179 @item --help
180 @opindex --help
181 Print a usage message listing all available options, then exit
182 successfully.
184 @item --version
185 @opindex --version
186 Print Emacs version, then exit successfully.
187 @end table
189 @node Initial Options
190 @appendixsec Initial Options
192   The initial options specify parameters for the Emacs session.  This
193 section describes the more general initial options; some other options
194 specifically related to the X Window System appear in the following
195 sections.
197   Some initial options affect the loading of the initialization file.
198 Normally, Emacs first loads @file{site-start.el} if it exists, then
199 your own initialization file if it exists, and finally the default
200 initialization file @file{default.el} if it exists (@pxref{Init
201 File}).  Certain options prevent loading of some of these files or
202 substitute other files for them.
204 @table @samp
205 @item -chdir @var{directory}
206 @opindex -chdir
207 @itemx --chdir=@var{directory}
208 @opindex --chdir
209 @cindex change Emacs directory
210 Change to @var{directory} before doing anything else.  This is mainly used
211 by session management in X so that Emacs starts in the same directory as it
212 stopped.  This makes desktop saving and restoring easier.
214 @item -t @var{device}
215 @opindex -t
216 @itemx --terminal=@var{device}
217 @opindex --terminal
218 @cindex device for Emacs terminal I/O
219 Use @var{device} as the device for terminal input and output.  This
220 option implies @samp{--no-window-system}.
222 @item -d @var{display}
223 @opindex -d
224 @itemx --display=@var{display}
225 @opindex --display
226 @cindex display for Emacs frame
227 Use the X Window System and use the display named @var{display} to open
228 the initial Emacs frame.  @xref{Display X}, for more details.
230 @item -nw
231 @opindex -nw
232 @itemx --no-window-system
233 @opindex --no-window-system
234 @cindex disable window system
235 Don't communicate directly with the window system, disregarding the
236 @env{DISPLAY} environment variable even if it is set.  This means that
237 Emacs uses the terminal from which it was launched for all its display
238 and input.
240 @cindex batch mode
241 @item -batch
242 @opindex --batch
243 @itemx --batch
244 Run Emacs in @dfn{batch mode}.  Batch mode is used for running
245 programs written in Emacs Lisp from shell scripts, makefiles, and so
246 on.  To invoke a Lisp program, use the @samp{-batch} option in
247 conjunction with one or more of @samp{-l}, @samp{-f} or @samp{--eval}
248 (@pxref{Action Arguments}).  @xref{Command Example}, for an example.
250 In batch mode, Emacs does not display the text being edited, and the
251 standard terminal interrupt characters such as @kbd{C-z} and @kbd{C-c}
252 have their usual effect.  Emacs functions that normally print a
253 message in the echo area will print to either the standard output
254 stream (@code{stdout}) or the standard error stream (@code{stderr})
255 instead.  (To be precise, functions like @code{prin1}, @code{princ}
256 and @code{print} print to @code{stdout}, while @code{message} and
257 @code{error} print to @code{stderr}.)  Functions that normally read
258 keyboard input from the minibuffer take their input from the
259 terminal's standard input stream (@code{stdin}) instead.
261 @samp{--batch} implies @samp{-q} (do not load an initialization file),
262 but @file{site-start.el} is loaded nonetheless.  It also causes Emacs
263 to exit after processing all the command options.  In addition, it
264 disables auto-saving except in buffers for which auto-saving is
265 explicitly requested, and when saving files it omits the @code{fsync}
266 system call unless otherwise requested.
268 @item --script @var{file}
269 @opindex --script
270 @cindex script mode
271 Run Emacs in batch mode, like @samp{--batch}, and then read and
272 execute the Lisp code in @var{file}.
274 The normal use of this option is in executable script files that run
275 Emacs.  They can start with this text on the first line
277 @example
278 #!/usr/bin/emacs --script
279 @end example
281 @noindent
282 which will invoke Emacs with @samp{--script} and supply the name of
283 the script file as @var{file}.  Emacs Lisp then treats the @samp{#!}
284 on this first line as a comment delimiter.
286 @item --no-build-details
287 @opindex --no-build-details
288 @cindex build details
289 @cindex deterministic build
290 Omit details like system name and build time from the Emacs executable,
291 so that builds are more deterministic.
293 @item -q
294 @opindex -q
295 @itemx --no-init-file
296 @opindex --no-init-file
297 @cindex bypassing init and @file{default.el} file
298 @cindex init file, not loading
299 @cindex @file{default.el} file, not loading
300 Do not load any initialization file (@pxref{Init File}).  When Emacs
301 is invoked with this option, the Customize facility does not allow
302 options to be saved (@pxref{Easy Customization}).  This option does
303 not disable loading @file{site-start.el}.
305 @item --no-site-file
306 @opindex --no-site-file
307 @cindex @file{site-start.el} file, not loading
308 Do not load @file{site-start.el} (@pxref{Init File}).  The @samp{-Q}
309 option does this too, but other options like @samp{-q} do not.
311 @item --no-site-lisp
312 @opindex --no-site-lisp
313 @cindex @file{site-start.el} file, not loading
314 Do not include the @file{site-lisp} directories in @code{load-path}
315 (@pxref{Init File}).  The @samp{-Q} option does this too.
317 @item --no-splash
318 @opindex --no-splash
319 @vindex inhibit-startup-screen
320 @cindex splash screen
321 @cindex startup message
322 Do not display a startup screen.  You can also achieve this effect by
323 setting the variable @code{inhibit-startup-screen} to non-@code{nil}
324 in your initialization file (@pxref{Entering Emacs}).
326 @item -Q
327 @opindex -Q
328 @itemx --quick
329 @opindex --quick
330 Start emacs with minimum customizations.  This is similar to using @samp{-q},
331 @samp{--no-site-file}, @samp{--no-site-lisp}, and @samp{--no-splash}
332 together.  This also stops Emacs from processing X resources by
333 setting @code{inhibit-x-resources} to @code{t} (@pxref{Resources}).
335 @item -daemon
336 @opindex -daemon
337 @itemx --daemon[=@var{name}]
338 @opindex --daemon
339 @itemx --old-daemon[=@var{name}]
340 @itemx --new-daemon[=@var{name}]
341 Start Emacs as a daemon---after Emacs starts up, it starts the Emacs
342 server without opening any frames.
343 (Optionally, you can specify an explicit @var{name} for the server.)
344 You can then use the @command{emacsclient} command to connect to Emacs
345 for editing.  @xref{Emacs Server}, for information about using Emacs
346 as a daemon.  An ``old-style'' daemon disconnects from the terminal
347 and runs in the background (@samp{--daemon} is an alias for
348 @samp{--old-daemon}).
350 @item --no-desktop
351 @opindex --no-desktop
352 Do not reload any saved desktop.  @xref{Saving Emacs Sessions}.
354 @item -u @var{user}
355 @opindex -u
356 @itemx --user=@var{user}
357 @opindex --user
358 @cindex load init file of another user
359 Load @var{user}'s initialization file instead of your
360 own@footnote{This option has no effect on MS-Windows.}.
362 @item --debug-init
363 @opindex --debug-init
364 @cindex errors in init file
365 Enable the Emacs Lisp debugger for errors in the init file.
366 @xref{Error Debugging,, Entering the Debugger on an Error, elisp, The
367 GNU Emacs Lisp Reference Manual}.
368 @end table
370 @node Command Example
371 @appendixsec Command Argument Example
373   Here is an example of using Emacs with arguments and options.  It
374 assumes you have a Lisp program file called @file{hack-c.el} which, when
375 loaded, performs some useful operation on the current buffer, expected
376 to be a C program.
378 @example
379 emacs --batch foo.c -l hack-c -f save-buffer >& log
380 @end example
382 @noindent
383 This says to visit @file{foo.c}, load @file{hack-c.el} (which makes
384 changes in the visited file), save @file{foo.c} (note that
385 @code{save-buffer} is the function that @kbd{C-x C-s} is bound to), and
386 then exit back to the shell (because of @samp{--batch}).  @samp{--batch}
387 also guarantees there will be no problem redirecting output to
388 @file{log}, because Emacs will not assume that it has a display terminal
389 to work with.
391 @node Environment
392 @appendixsec Environment Variables
393 @cindex environment variables
395   The @dfn{environment} is a feature of the operating system; it
396 consists of a collection of variables with names and values.  Each
397 variable is called an @dfn{environment variable}; environment variable
398 names are case-sensitive, and it is conventional to use upper case
399 letters only.  The values are all text strings.
401   What makes the environment useful is that subprocesses inherit the
402 environment automatically from their parent process.  This means you
403 can set up an environment variable in your login shell, and all the
404 programs you run (including Emacs) will automatically see it.
405 Subprocesses of Emacs (such as shells, compilers, and version control
406 programs) inherit the environment from Emacs, too.
408 @findex setenv
409 @findex getenv
410 @vindex initial-environment
411   Inside Emacs, the command @kbd{M-x getenv} reads the name of an
412 environment variable, and prints its value in the echo area.  @kbd{M-x
413 setenv} sets a variable in the Emacs environment, and @kbd{C-u M-x
414 setenv} removes a variable.  (Environment variable substitutions with
415 @samp{$} work in the value just as in file names; see @ref{File Names
416 with $}.)  The variable @code{initial-environment} stores the initial
417 environment inherited by Emacs.
419   The way to set environment variables outside of Emacs depends on the
420 operating system, and especially the shell that you are using.  For
421 example, here's how to set the environment variable @env{ORGANIZATION}
422 to @samp{not very much} using Bash:
424 @example
425 export ORGANIZATION="not very much"
426 @end example
428 @noindent
429 and here's how to do it in csh or tcsh:
431 @example
432 setenv ORGANIZATION "not very much"
433 @end example
435   When Emacs is using the X Window System, various environment
436 variables that control X work for Emacs as well.  See the X
437 documentation for more information.
439 @menu
440 * General Variables::   Environment variables that all versions of Emacs use.
441 * Misc Variables::      Certain system-specific variables.
442 * MS-Windows Registry:: An alternative to the environment on MS-Windows.
443 @end menu
445 @node General Variables
446 @appendixsubsec General Variables
448   Here is an alphabetical list of environment variables that have
449 special meanings in Emacs.  Most of these variables are also used by
450 some other programs.  Emacs does not require any of these environment
451 variables to be set, but it uses their values if they are set.
453 @c This used to be @vtable, but that enters the variables alone into
454 @c the Variable Index, which in some cases, like HOME, might be
455 @c confused with keys by that name, and other cases, like NAME,
456 @c might be confused with general-purpose phrases.
457 @table @env
458 @item CDPATH
459 @vindex CDPATH, environment variable
460 Used by the @code{cd} command to search for the directory you specify,
461 when you specify a relative directory name.
462 @item DBUS_SESSION_BUS_ADDRESS
463 @vindex DBUS_SESSION_BUS_ADDRESS, environment variable
464 Used by D-Bus when Emacs is compiled with it.  Usually, there is no
465 need to change it.  Setting it to a dummy address, like
466 @samp{unix:path=/dev/null}, suppresses connections to the D-Bus session
467 bus as well as autolaunching the D-Bus session bus if not running yet.
468 @item EMACSDATA
469 @vindex EMACSDATA, environment variable
470 Directory for the architecture-independent files that come with Emacs.
471 This is used to initialize the variable @code{data-directory}.
472 @item EMACSDOC
473 #vindex EMACSDOC, environment variable
474 Directory for the documentation string file, which is used to
475 initialize the Lisp variable @code{doc-directory}.
476 @item EMACSLOADPATH
477 #vindex EMACSLOADPATH, environment variable
478 A colon-separated list of directories@footnote{Here and below,
479 whenever we say ``colon-separated list of directories'', it pertains
480 to Unix and GNU/Linux systems.  On MS-DOS and MS-Windows, the
481 directories are separated by semi-colons instead, since DOS/Windows
482 file names might include a colon after a drive letter.} to search for
483 Emacs Lisp files.  If set, it modifies the usual initial value of the
484 @code{load-path} variable (@pxref{Lisp Libraries}).  An empty element
485 stands for the default value of @code{load-path}; e.g., using
486 @samp{EMACSLOADPATH="/tmp:"} adds @file{/tmp} to the front of
487 the default @code{load-path}.  To specify an empty element in the
488 middle of the list, use 2 colons in a row, as in
489 @samp{EMACSLOADPATH="/tmp::/foo"}.
490 @item EMACSPATH
491 @vindex EMACSPATH, environment variable
492 A colon-separated list of directories to search for executable files.
493 If set, Emacs uses this in addition to @env{PATH} (see below) when
494 initializing the variable @code{exec-path} (@pxref{Shell}).
495 @item EMAIL
496 @vindex EMAIL, environment variable
497 @vindex user-mail-address@r{, initialization}
498 Your email address; used to initialize the Lisp variable
499 @code{user-mail-address}, which the Emacs mail interface puts into the
500 @samp{From} header of outgoing messages (@pxref{Mail Headers}).
501 @item ESHELL
502 @vindex ESHELL, environment variable
503 Used for shell-mode to override the @env{SHELL} environment variable
504 (@pxref{Interactive Shell}).
505 @item HISTFILE
506 @vindex HISTFILE, environment variable
507 The name of the file that shell commands are saved in between logins.
508 This variable defaults to @file{~/.bash_history} if you use Bash, to
509 @file{~/.sh_history} if you use ksh, and to @file{~/.history}
510 otherwise.
511 @item HOME
512 @vindex HOME, environment variable
513 The location of your files in the directory tree; used for
514 expansion of file names starting with a tilde (@file{~}).  On MS-DOS,
515 it defaults to the directory from which Emacs was started, with
516 @samp{/bin} removed from the end if it was present.  On Windows, the
517 default value of @env{HOME} is the @file{Application Data}
518 subdirectory of the user profile directory (normally, this is
519 @file{C:/Documents and Settings/@var{username}/Application Data},
520 where @var{username} is your user name), though for backwards
521 compatibility @file{C:/} will be used instead if a @file{.emacs} file
522 is found there.
523 @item HOSTNAME
524 @vindex HOSTNAME, environment variable
525 The name of the machine that Emacs is running on.
526 @c complete.el is obsolete since 24.1.
527 @ignore
528 @item INCPATH
529 A colon-separated list of directories.  Used by the @code{complete} package
530 to search for files.
531 @end ignore
532 @item INFOPATH
533 @vindex INFOPATH, environment variable
534 A colon-separated list of directories in which to search for Info files.
535 @item LC_ALL
536 @vindex LC_ALL, environment variable
537 @itemx LC_COLLATE
538 @vindex LC_COLLATE, environment variable
539 @itemx LC_CTYPE
540 @vindex LC_CTYPE, environment variable
541 @itemx LC_MESSAGES
542 @vindex LC_MESSAGES, environment variable
543 @itemx LC_MONETARY
544 @vindex LC_MONETARY, environment variable
545 @itemx LC_NUMERIC
546 @vindex LC_NUMERIC, environment variable
547 @itemx LC_TIME
548 @vindex LC_TIME, environment variable
549 @itemx LANG
550 @vindex LANG, environment variable
551 The user's preferred locale.  The locale has six categories, specified
552 by the environment variables @env{LC_COLLATE} for sorting,
553 @env{LC_CTYPE} for character encoding, @env{LC_MESSAGES} for system
554 messages, @env{LC_MONETARY} for monetary formats, @env{LC_NUMERIC} for
555 numbers, and @env{LC_TIME} for dates and times.  If one of these
556 variables is not set, the category defaults to the value of the
557 @env{LANG} environment variable, or to the default @samp{C} locale if
558 @env{LANG} is not set.  But if @env{LC_ALL} is specified, it overrides
559 the settings of all the other locale environment variables.
561 On MS-Windows and macOS, if @env{LANG} is not already set in the
562 environment, Emacs sets it based on the system-wide default.  You can
563 set this in the ``Regional Settings'' Control Panel on some versions
564 of MS-Windows, and in the ``Language and Region'' System Preference on
565 macOS.
567 The value of the @env{LC_CTYPE} category is
568 matched against entries in @code{locale-language-names},
569 @code{locale-charset-language-names}, and
570 @code{locale-preferred-coding-systems}, to select a default language
571 environment and coding system.  @xref{Language Environments}.
572 @item LOGNAME
573 @vindex LOGNAME, environment variable
574 The user's login name.  See also @env{USER}.
575 @item MAIL
576 @vindex MAIL, environment variable
577 The name of your system mail inbox.
578 @ifnottex
579 @item MH
580 @vindex MH, environment variable
581 Name of setup file for the mh system.  @xref{Top,,MH-E,mh-e, The Emacs
582 Interface to MH}.
583 @end ifnottex
584 @item NAME
585 @vindex NAME, environment variable
586 Your real-world name.  This is used to initialize the variable
587 @code{user-full-name} (@pxref{Mail Headers}).
588 @item NNTPSERVER
589 @vindex NNTPSERVER, environment variable
590 The name of the news server.  Used by the mh and Gnus packages.
591 @item ORGANIZATION
592 @vindex ORGANIZATION, environment variable
593 The name of the organization to which you belong.  Used for setting the
594 @samp{Organization:} header in your posts from the Gnus package.
595 @item PATH
596 @vindex PATH, environment variable
597 A colon-separated list of directories containing executable files.
598 This is used to initialize the variable @code{exec-path}
599 (@pxref{Shell}).
600 @item PWD
601 @vindex PWD, environment variable
602 If set, this should be the default directory when Emacs was started.
603 @item REPLYTO
604 @vindex REPLYTO, environment variable
605 If set, this specifies an initial value for the variable
606 @code{mail-default-reply-to} (@pxref{Mail Headers}).
607 @item SAVEDIR
608 @vindex SAVEDIR, environment variable
609 The name of a directory in which news articles are saved by default.
610 Used by the Gnus package.
611 @item SHELL
612 @vindex SHELL, environment variable
613 The name of an interpreter used to parse and execute programs run from
614 inside Emacs.
615 @item SMTPSERVER
616 @vindex SMTPSERVER, environment variable
617 The name of the outgoing mail server.  This is used to initialize the
618 variable @code{smtpmail-smtp-server} (@pxref{Mail Sending}).
619 @cindex background mode, on @command{xterm}
620 @item TERM
621 @vindex TERM, environment variable
622 The type of the terminal that Emacs is using.  This variable must be
623 set unless Emacs is run in batch mode.  On MS-DOS, it defaults to
624 @samp{internal}, which specifies a built-in terminal emulation that
625 handles the machine's own display.
626 @item TERMCAP
627 @vindex TERMCAP, environment variable
628 The name of the termcap library file describing how to program the
629 terminal specified by @env{TERM}.  This defaults to
630 @file{/etc/termcap}.
631 @item TMPDIR
632 @vindex TMPDIR, environment variable
633 @itemx TMP
634 @vindex TMP, environment variable
635 @itemx TEMP
636 @vindex TEMP, environment variable
637 These environment variables are used to initialize the variable
638 @code{temporary-file-directory}, which specifies a directory in which
639 to put temporary files (@pxref{Backup}).  Emacs tries to use
640 @env{TMPDIR} first.  If that is unset, Emacs normally falls back on
641 @file{/tmp}, but on MS-Windows and MS-DOS it instead falls back on
642 @env{TMP}, then @env{TEMP}, and finally @file{c:/temp}.
643 @item TZ
644 @vindex TZ, environment variable
645 This specifies the default time zone and possibly also daylight
646 saving time information.  @xref{Time Zone Rules,,, elisp, The GNU
647 Emacs Lisp Reference Manual}.  On MS-DOS, if @env{TZ} is not set in the
648 environment when Emacs starts, Emacs defines a default value as
649 appropriate for the country code returned by DOS@.  On MS-Windows, Emacs
650 does not use @env{TZ} at all.
651 @item USER
652 @vindex USER, environment variable
653 The user's login name.  See also @env{LOGNAME}.  On MS-DOS, this
654 defaults to @samp{root}.
655 @item VERSION_CONTROL
656 @vindex VERSION_CONTROL, environment variable
657 Used to initialize the @code{version-control} variable (@pxref{Backup
658 Names}).
659 @end table
661 @node Misc Variables
662 @appendixsubsec Miscellaneous Variables
664 These variables are used only on particular configurations:
666 @vtable @env
667 @item COMSPEC
668 On MS-DOS and MS-Windows, the name of the command interpreter to use
669 when invoking batch files and commands internal to the shell.  On MS-DOS
670 this is also used to make a default value for the @env{SHELL} environment
671 variable.
673 @item NAME
674 On MS-DOS, this variable defaults to the value of the @env{USER}
675 variable.
677 @item EMACSTEST
678 On MS-DOS, this specifies a file to use to log the operation of the
679 internal terminal emulator.  This feature is useful for submitting bug
680 reports.
682 @item EMACSCOLORS
683 On MS-DOS, this specifies the screen colors.  It is useful to set them
684 this way, since otherwise Emacs would display the default colors
685 momentarily when it starts up.
687 The value of this variable should be the two-character encoding of the
688 foreground (the first character) and the background (the second
689 character) colors of the default face.  Each character should be the
690 hexadecimal code for the desired color on a standard PC text-mode
691 display.  For example, to get blue text on a light gray background,
692 specify @samp{EMACSCOLORS=17}, since 1 is the code of the blue color and
693 7 is the code of the light gray color.
695 The PC display usually supports only eight background colors.  However,
696 Emacs switches the DOS display to a mode where all 16 colors can be used
697 for the background, so all four bits of the background color are
698 actually used.
700 @item PRELOAD_WINSOCK
701 On MS-Windows, if you set this variable, Emacs will load and initialize
702 the network library at startup, instead of waiting until the first
703 time it is required.
705 @item emacs_dir
706 On MS-Windows, @env{emacs_dir} is a special environment variable, which
707 indicates the full path of the directory in which Emacs is installed.
708 If Emacs is installed in the standard directory structure, it
709 calculates this value automatically.  It is not much use setting this
710 variable yourself unless your installation is non-standard, since
711 unlike other environment variables, it will be overridden by Emacs at
712 startup.  When setting other environment variables, such as
713 @env{EMACSLOADPATH}, you may find it useful to use @env{emacs_dir}
714 rather than hard-coding an absolute path.  This allows multiple
715 versions of Emacs to share the same environment variable settings, and
716 it allows you to move the Emacs installation directory, without
717 changing any environment or registry settings.
718 @end vtable
720 @node MS-Windows Registry
721 @appendixsubsec The MS-Windows System Registry
722 @pindex addpm, MS-Windows installation program
723 @cindex registry, setting environment variables (MS-Windows)
725 On MS-Windows, the installation program @command{addpm.exe} adds
726 values for @env{emacs_dir}, @env{EMACSLOADPATH}, @env{EMACSDATA},
727 @env{EMACSPATH}, @env{EMACSDOC}, @env{SHELL} and @env{TERM} to the
728 @file{HKEY_LOCAL_MACHINE} section of the system registry, under
729 @file{/Software/GNU/Emacs}.  It does this because there is no standard
730 place to set environment variables across different versions of
731 Windows.  Running @command{addpm.exe} is no longer strictly necessary
732 in recent versions of Emacs, but if you are upgrading from an older
733 version, running @command{addpm.exe} ensures that you do not have
734 older registry entries from a previous installation, which may not be
735 compatible with the latest version of Emacs.
737 When Emacs starts, as well as checking the environment, it also checks
738 the System Registry for those variables and for @env{HOME}, @env{LANG}
739 and @env{PRELOAD_WINSOCK}.
741 To determine the value of those variables, Emacs goes through the
742 following procedure.  First, the environment is checked.  If the
743 variable is not found there, Emacs looks for registry keys by that
744 name under @file{/Software/GNU/Emacs}; first in the
745 @file{HKEY_CURRENT_USER} section of the registry, and if not found
746 there, in the @file{HKEY_LOCAL_MACHINE} section.  Finally, if Emacs
747 still cannot determine the values, compiled-in defaults are used.
749 In addition to the environment variables above, you can also add many
750 of the settings which on X belong in the @file{.Xdefaults} file
751 (@pxref{X Resources}) to the @file{/Software/GNU/Emacs} registry key.
753 @node Display X
754 @appendixsec Specifying the Display Name
755 @cindex display name (X Window System)
756 @cindex @env{DISPLAY} environment variable
758   The environment variable @env{DISPLAY} tells all X clients,
759 including Emacs, where to display their windows.  Its value is set by
760 default in ordinary circumstances, when you start an X server and run
761 jobs locally.  You can specify the display yourself; one reason to do
762 this is if you want to log into another system and run Emacs there,
763 and have the window displayed at your local terminal.
765   @env{DISPLAY} has the syntax
766 @samp{@var{host}:@var{display}.@var{screen}}, where @var{host} is the
767 host name of the X Window System server machine, @var{display} is an
768 arbitrarily-assigned number that distinguishes your server (X
769 terminal) from other servers on the same machine, and @var{screen} is
770 a field that allows an X server to control multiple terminal screens.
771 The period and the @var{screen} field are optional.  If included,
772 @var{screen} is usually zero.
774   For example, if your host is named @samp{glasperle} and your server is
775 the first (or perhaps the only) server listed in the configuration, your
776 @env{DISPLAY} is @samp{glasperle:0.0}.
778   You can specify the display name explicitly when you run Emacs, either
779 by changing the @env{DISPLAY} variable, or with the option @samp{-d
780 @var{display}} or @samp{--display=@var{display}}.  Here is an example:
782 @smallexample
783 emacs --display=glasperle:0 &
784 @end smallexample
786   You can inhibit the use of the X window system with the @samp{-nw}
787 option.  Then Emacs uses its controlling text terminal for display.
788 @xref{Initial Options}.
790   Sometimes, security arrangements prevent a program on a remote system
791 from displaying on your local system.  In this case, trying to run Emacs
792 produces messages like this:
794 @smallexample
795 Xlib:  connection to "glasperle:0.0" refused by server
796 @end smallexample
798 @noindent
799 You might be able to overcome this problem by using the @command{xhost}
800 command on the local system to give permission for access from your
801 remote machine.
803 @node Font X
804 @appendixsec Font Specification Options
805 @cindex font name (X Window System)
807 You can use the command line option @samp{-fn @var{font}} (or
808 @samp{--font}, which is an alias for @samp{-fn}) to specify a default
809 font:
811 @table @samp
812 @item -fn @var{font}
813 @opindex -fn
814 @itemx --font=@var{font}
815 @opindex --font
816 @cindex specify default font from the command line
817 Use @var{font} as the default font.
818 @end table
820 When passing a font name to Emacs on the command line, you may need to
821 quote it, by enclosing it in quotation marks, if it contains
822 characters that the shell treats specially (e.g., spaces).  For
823 example:
825 @smallexample
826 emacs -fn "DejaVu Sans Mono-12"
827 @end smallexample
829 @xref{Fonts}, for details about font names and other ways to specify
830 the default font.
832 @node Colors X
833 @appendixsec Window Color Options
834 @cindex color of window, from command line
835 @cindex text colors, from command line
837   You can use the following command-line options to specify the colors
838 to use for various parts of the Emacs display.  Colors may be
839 specified using either color names or RGB triplets (@pxref{Colors}).
841 @table @samp
842 @item -fg @var{color}
843 @opindex -fg
844 @itemx --foreground-color=@var{color}
845 @opindex --foreground-color
846 @cindex foreground color, command-line argument
847 Specify the foreground color, overriding the color specified by the
848 @code{default} face (@pxref{Faces}).
849 @item -bg @var{color}
850 @opindex -bg
851 @itemx --background-color=@var{color}
852 @opindex --background-color
853 @cindex background color, command-line argument
854 Specify the background color, overriding the color specified by the
855 @code{default} face.
856 @item -bd @var{color}
857 @opindex -bd
858 @itemx --border-color=@var{color}
859 @opindex --border-color
860 @cindex border color, command-line argument
861 Specify the color of the border of the X window.  This has no effect
862 if Emacs is compiled with GTK+ support.
863 @item -cr @var{color}
864 @opindex -cr
865 @itemx --cursor-color=@var{color}
866 @opindex --cursor-color
867 @cindex cursor color, command-line argument
868 Specify the color of the Emacs cursor which indicates where point is.
869 @item -ms @var{color}
870 @opindex -ms
871 @itemx --mouse-color=@var{color}
872 @opindex --mouse-color
873 @cindex mouse pointer color, command-line argument
874 Specify the color for the mouse cursor when the mouse is in the Emacs window.
875 @item -r
876 @opindex -r
877 @itemx -rv
878 @opindex -rv
879 @itemx --reverse-video
880 @opindex --reverse-video
881 @cindex reverse video, command-line argument
882 Reverse video---swap the foreground and background colors.
883 @item --color=@var{mode}
884 @opindex --color
885 @cindex standard colors on a character terminal
886 @cindex override character terminal color support
887 Set the @dfn{color support mode} when Emacs is run on a text terminal.
888 This option overrides the number of supported colors that the
889 character terminal advertises in its @code{termcap} or @code{terminfo}
890 database.  The parameter @var{mode} can be one of the following:
891 @table @samp
892 @item never
893 @itemx no
894 Don't use colors even if the terminal's capabilities specify color
895 support.
896 @item default
897 @itemx auto
898 Same as when @option{--color} is not used at all: Emacs detects at
899 startup whether the terminal supports colors, and if it does, turns on
900 colored display.
901 @item always
902 @itemx yes
903 @itemx ansi8
904 Turn on the color support unconditionally, and use color commands
905 specified by the ANSI escape sequences for the 8 standard colors.
906 @item @var{num}
907 Use color mode for @var{num} colors.  If @var{num} is -1, turn off
908 color support (equivalent to @samp{never}); if it is 0, use the
909 default color support for this terminal (equivalent to @samp{auto});
910 otherwise use an appropriate standard mode for @var{num} colors.
911 Depending on your terminal's capabilities, Emacs might be able to turn
912 on a color mode for 8, 16, 88, or 256 as the value of @var{num}.  If
913 there is no mode that supports @var{num} colors, Emacs acts as if
914 @var{num} were 0, i.e., it uses the terminal's default color support
915 mode.
916 @end table
917 If @var{mode} is omitted, it defaults to @var{ansi8}.
918 @end table
920   For example, to use a coral mouse cursor and a slate blue text cursor,
921 enter:
923 @example
924 emacs -ms coral -cr 'slate blue' &
925 @end example
927   You can reverse the foreground and background colors through the
928 @samp{-rv} option or with the X resource @samp{reverseVideo}.
930   The @samp{-fg}, @samp{-bg}, and @samp{-rv} options function on text
931 terminals as well as on graphical displays.
933 @node Window Size X
934 @appendixsec Options for Window Size and Position
935 @cindex geometry of Emacs window
936 @cindex position and size of Emacs frame
937 @cindex width and height of Emacs frame
938 @cindex specifying fullscreen for Emacs frame
940   Here is a list of the command-line options for specifying size and
941 position of the initial Emacs frame:
943 @table @samp
944 @item -g @var{width}x@var{height}@r{[@{}+-@r{@}}@var{xoffset}@r{@{}+-@r{@}}@var{yoffset}@r{]]}
945 @opindex -g
946 @itemx --geometry=@var{width}x@var{height}@r{[@{}+-@r{@}}@var{xoffset}@r{@{}+-@r{@}}@var{yoffset}@r{]]}
947 @opindex --geometry
948 @cindex geometry, command-line argument
949 Specify the size @var{width} and @var{height} (measured in character
950 columns and lines), and positions @var{xoffset} and @var{yoffset}
951 (measured in pixels).  The @var{width} and @var{height} parameters
952 apply to all frames, whereas @var{xoffset} and @var{yoffset} only to
953 the initial frame.
955 @item -fs
956 @opindex -fs
957 @itemx --fullscreen
958 @opindex --fullscreen
959 @cindex fullscreen, command-line argument
960 Specify that width and height should be that of the screen.  Normally
961 no window manager decorations are shown.  (After starting Emacs,
962 you can toggle this state using @key{F11}, @code{toggle-frame-fullscreen}.)
964 @item -mm
965 @opindex -mm
966 @itemx --maximized
967 @opindex --maximized
968 @cindex maximized, command-line argument
969 Specify that the Emacs frame should be maximized.  This normally
970 means that the frame has window manager decorations.
971 (After starting Emacs, you can toggle this state using @kbd{M-F10},
972 @code{toggle-frame-maximized}.)
974 @item -fh
975 @opindex -fh
976 @itemx --fullheight
977 @opindex --fullheight
978 @cindex fullheight, command-line argument
979 Specify that the height should be the height of the screen.
981 @item -fw
982 @opindex -fw
983 @itemx --fullwidth
984 @opindex --fullwidth
985 @cindex fullwidth, command-line argument
986 Specify that the width should be the width of the screen.
987 @end table
989 @noindent
990 In the @samp{--geometry} option, @code{@r{@{}+-@r{@}}} means either a plus
991  sign or a minus sign.  A plus
992 sign before @var{xoffset} means it is the distance from the left side of
993 the screen; a minus sign means it counts from the right side.  A plus
994 sign before @var{yoffset} means it is the distance from the top of the
995 screen, and a minus sign there indicates the distance from the bottom.
996 The values @var{xoffset} and @var{yoffset} may themselves be positive or
997 negative, but that doesn't change their meaning, only their direction.
999   Emacs uses the same units as @command{xterm} does to interpret the geometry.
1000 The @var{width} and @var{height} are measured in characters, so a large font
1001 creates a larger frame than a small font.  (If you specify a proportional
1002 font, Emacs uses its maximum bounds width as the width unit.)  The
1003 @var{xoffset} and @var{yoffset} are measured in pixels.
1005   You do not have to specify all of the fields in the geometry
1006 specification.  If you omit both @var{xoffset} and @var{yoffset}, the
1007 window manager decides where to put the Emacs frame, possibly by
1008 letting you place it with the mouse.  For example, @samp{164x55}
1009 specifies a window 164 columns wide, enough for two ordinary width
1010 windows side by side, and 55 lines tall.
1012   The default frame width is 80 characters and the default height is
1013 40 lines.  You can omit either the width or the height or both.  If
1014 you start the geometry with an integer, Emacs interprets it as the
1015 width.  If you start with an @samp{x} followed by an integer, Emacs
1016 interprets it as the height.  Thus, @samp{81} specifies just the
1017 width; @samp{x45} specifies just the height.
1019   If you start with @samp{+} or @samp{-}, that introduces an offset,
1020 which means both sizes are omitted.  Thus, @samp{-3} specifies the
1021 @var{xoffset} only.  (If you give just one offset, it is always
1022 @var{xoffset}.)  @samp{+3-3} specifies both the @var{xoffset} and the
1023 @var{yoffset}, placing the frame near the bottom left of the screen.
1025   You can specify a default for any or all of the fields in your X
1026 resource file (@pxref{Resources}), and then override selected fields
1027 with a @samp{--geometry} option.
1029   Since the mode line and the echo area occupy the last 2 lines of the
1030 frame, the height of the initial text window is 2 less than the height
1031 specified in your geometry.  In non-X-toolkit versions of Emacs, the
1032 menu bar also takes one line of the specified number.  But in the X
1033 toolkit version, the menu bar is additional and does not count against
1034 the specified height.  The tool bar, if present, is also additional.
1036   Enabling or disabling the menu bar or tool bar alters the amount of
1037 space available for ordinary text.  Therefore, if Emacs starts up with
1038 a tool bar (which is the default), and handles the geometry
1039 specification assuming there is a tool bar, and then your
1040 initialization file disables the tool bar, you will end up with a
1041 frame geometry different from what you asked for.  To get the intended
1042 size with no tool bar, use an X resource to specify ``no tool bar''
1043 (@pxref{Table of Resources}); then Emacs will already know there's no
1044 tool bar when it processes the specified geometry.
1046   When using one of @samp{--fullscreen}, @samp{--maximized},
1047 @samp{--fullwidth} or @samp{--fullheight}, some window managers require
1048 you to set the variable @code{frame-resize-pixelwise} to a non-@code{nil}
1049 value to make a frame appear truly maximized or full-screen.
1051  Some window managers have options that can make them ignore both
1052 program-specified and user-specified positions.  If these are set,
1053 Emacs fails to position the window correctly.
1055 @node Borders X
1056 @appendixsec Internal and External Borders
1057 @cindex borders (X Window System)
1059   An Emacs frame has an internal border and an external border.  The
1060 internal border is an extra strip of the background color around the
1061 text portion of the frame.  Emacs itself draws the internal border.
1062 The external border is added by the window manager outside the frame;
1063 depending on the window manager you use, it may contain various boxes
1064 you can click on to move or iconify the window.
1066 @table @samp
1067 @item -ib @var{width}
1068 @opindex -ib
1069 @itemx --internal-border=@var{width}
1070 @opindex --internal-border
1071 @cindex internal border width, command-line argument
1072 Specify @var{width} as the width of the internal border (between the text
1073 and the main border), in pixels.
1075 @item -bw @var{width}
1076 @opindex -bw
1077 @itemx --border-width=@var{width}
1078 @opindex --border-width
1079 @cindex main border width, command-line argument
1080 Specify @var{width} as the width of the main border, in pixels.
1081 @end table
1083   When you specify the size of the frame, that does not count the
1084 borders.  The frame's position is measured from the outside edge of the
1085 external border.
1087   Use the @samp{-ib @var{n}} option to specify an internal border
1088 @var{n} pixels wide.  The default is 1.  Use @samp{-bw @var{n}} to
1089 specify the width of the external border (though the window manager may
1090 not pay attention to what you specify).  The default width of the
1091 external border is 2.
1093 @node Title X
1094 @appendixsec Frame Titles
1096   An Emacs frame may or may not have a specified title.  The frame
1097 title, if specified, appears in window decorations and icons as the
1098 name of the frame.  If an Emacs frame has no specified title, the
1099 default title has the form @samp{@var{invocation-name}@@@var{machine}}
1100 (if there is only one frame) or the selected window's buffer name (if
1101 there is more than one frame).
1103   You can specify a title for the initial Emacs frame with a command
1104 line option:
1106 @table @samp
1107 @item -T @var{title}
1108 @opindex -T
1109 @itemx --title=@var{title}
1110 @opindex --title
1111 @cindex frame title, command-line argument
1112 Specify @var{title} as the title for the initial Emacs frame.
1113 @end table
1115   The @samp{--name} option (@pxref{Resources}) also specifies the title
1116 for the initial Emacs frame.
1118 @node Icons X
1119 @appendixsec Icons
1120 @cindex icons (X Window System)
1121 @cindex minimizing a frame at startup
1123 @table @samp
1124 @item -iconic
1125 @opindex --iconic
1126 @itemx --iconic
1127 @cindex start iconified, command-line argument
1128 Start Emacs in an iconified state.
1130 @item -nbi
1131 @opindex -nbi
1132 @itemx --no-bitmap-icon
1133 @opindex --no-bitmap-icon
1134 @cindex Emacs icon, a gnu
1135 Disable the use of the Emacs icon.
1136 @end table
1138   Most window managers allow you to iconify (or ``minimize'') an
1139 Emacs frame, hiding it from sight.  Some window managers replace
1140 iconified windows with tiny icons, while others remove them
1141 entirely from sight.  The @samp{-iconic} option tells Emacs to begin
1142 running in an iconified state, rather than showing a frame right away.
1143 The text frame doesn't appear until you deiconify (or ``un-minimize'')
1146   By default, Emacs uses an icon containing the Emacs logo.  On
1147 desktop environments such as Gnome, this icon is also displayed in
1148 other contexts, e.g., when switching into an Emacs frame.  The
1149 @samp{-nbi} or @samp{--no-bitmap-icon} option tells Emacs to let the
1150 window manager choose what sort of icon to use---usually just a small
1151 rectangle containing the frame's title.
1153 @node Misc X
1154 @appendixsec Other Display Options
1156 @table @samp
1157 @c @item -hb
1158 @c @opindex -hb
1159 @c @itemx --horizontal-scroll-bars
1160 @c @opindex --horizontal-scroll-bars
1161 @c @c @cindex horizontal scroll bars, command-line argument
1162 @c Enable horizontal scroll bars.  Since horizontal scroll bars
1163 @c are not yet implemented, this actually does nothing.
1165 @item --parent-id @var{id}
1166 Open Emacs as a client X window via the XEmbed protocol, with @var{id}
1167 as the parent X window id.  Currently, this option is mainly useful
1168 for developers.
1170 @item -vb
1171 @opindex -vb
1172 @itemx --vertical-scroll-bars
1173 @opindex --vertical-scroll-bars
1174 @cindex vertical scroll bars, command-line argument
1175 Enable vertical scroll bars.
1177 @item -lsp @var{pixels}
1178 @opindex -lsp
1179 @itemx --line-spacing=@var{pixels}
1180 @opindex --line-spacing
1181 @cindex line spacing, command-line argument
1182 Specify @var{pixels} as additional space to put between lines, in pixels.
1184 @item -nbc
1185 @opindex -nbc
1186 @itemx --no-blinking-cursor
1187 @opindex --no-blinking-cursor
1188 @cindex blinking cursor disable, command-line argument
1189 Disable the blinking cursor on graphical displays.
1191 @item -D
1192 @opindex -D
1193 @itemx --basic-display
1194 @opindex --basic-display
1195 Disable the menu-bar, the tool-bar, the scroll-bars, and tool tips,
1196 and turn off the blinking cursor.  This can be useful for making a
1197 test case that simplifies debugging of display problems.
1198 @end table
1200   The @samp{--xrm} option (@pxref{Resources}) specifies additional
1201 X resource values.