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