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