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