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