(lemacs.info)Command Switches


Next: Basic Prev: Exiting Up: Top

Command Line Switches and Arguments
===================================

   GNU Emacs supports command line arguments you can use to request
various actions when invoking Emacs.  The commands are for compatibility
with other editors and for sophisticated activities.  If you are using
Lucid Emacs under the X window system, you can also use a number of
standard Xt command line arguments. Command line arguments are not
usually needed for editing with Emacs; new users can skip this section.

   Many editors are designed to be started afresh each time you want to
edit.  You start the editor to edit one file; then exit the editor.  The
next time you want to edit either another file or the same one, you
start the editor again.  Under these circumstances, it makes sense to
use a command line argument to say which file to edit.

   The recommended way to use GNU Emacs is to start it only once, just
after you log in, and do all your editing in the same Emacs process.
Each time you want to edit a file, you visit it using the existing
Emacs.  Emacs creates a new buffer for each file, and (unless you kill
some of the buffers) Emacs eventually has many files in it ready for
editing.  Usually you do not kill the Emacs process until you are about
to log out.  Since you usually read files by typing commands to Emacs,
command line arguments for specifying a file when Emacs is started are
seldom needed.

   Emacs accepts command-line arguments that specify files to visit,
functions to call, and other activities and operating modes.  If you are
running Lucid Emacs under the X window system, a number of standard Xt
command line arguments are available as well.

   The following subsections list:
   * Command line arguments that you can always use

   * Command line arguments that have to appear at the beginning of the
     argument list

   * Command line arguments that are only relevant if you are running
     Lucid Emacs under X

Command Line Arguments for Any Position
---------------------------------------

   Command line arguments are processed in the order they appear on the
command line; however, certain arguments (the ones in the second table)
must be at the front of the list if they are used.

   Here are the arguments allowed:

`FILE'
     Visit FILE using `find-file'.  Note: Visiting.

`+LINENUM FILE'
     Visit FILE using `find-file', then go to line number LINENUM in it.

`-load FILE'
`-l FILE'
     Load a file FILE of Lisp code with the function `load'.  *Note
     Lisp Libraries::.

`-funcall FUNCTION'
`-f FUNCTION'
     Call Lisp function FUNCTION with no arguments.

`-eval FUNCTION'
     Interpret the next argument as a Lisp expression, and evaluate it.
     You must be very careful of the shell quoting here.

`-insert FILE'
`-i FILE'
     Insert the contents of FILE into the current buffer.  This is like
     what `M-x insert-buffer' does; Note: Misc File Ops.

`-kill'
     Exit from Emacs without asking for confirmation.

`-version'
     Prints version information.  This implies `-batch'.

          % emacs -version
          GNU Emacs 19.6 Lucid of Thu Apr  1 1993 on thalidomide (berkeley-unix)

`-help'
     Prints a summary of command-line options and then exits.

Command Line Arguments (Beginning of Line Only)
-----------------------------------------------

   The following arguments are recognized only at the beginning of the
command line.  If more than one of them appears, they must appear in the
order in which they appear in this table.

`-t FILE'
     Use FILE instead of the terminal for input and output. (This
     option is currently not valid in Lucid Emacs.)

`-batch'
     Run Emacs in "batch mode", which means that the text being edited
     is not displayed and the standard Unix interrupt characters such as
     `C-z' and `C-c' continue to have their normal effect.  Emacs in
     batch mode outputs to `stderr' only what would normally be printed
     in the echo area under program control.

     Batch mode is used for running programs written in Emacs Lisp from
     shell scripts, makefiles, and so on.  Normally the `-l' switch or
     `-f' switch will be used as well, to invoke a Lisp program to do
     the batch processing.

     `-batch' implies `-q' (do not load an init file).  It also causes
     Emacs to kill itself after all command switches have been
     processed.  In addition, auto-saving is not done except in buffers
     for which it has been explicitly requested.

`-no-init-file'
`-q'
     Do not load your Emacs init file `~/.emacs'.

`-no-site-file'
     Do not load the site-specific init file `lisp/site-start.el'.

`-user USER'
`-u USER'
     Load USER's Emacs init file `~USER/.emacs' instead of your own.

   Note that the init file can get access to the command line argument
values as the elements of a list in the variable `command-line-args'.
(The arguments in the second table above will already have been
processed and will not be in the list.)  The init file can override the
normal processing of the other arguments by setting this variable.

   One way to use command switches is to visit many files automatically:

     emacs *.c

passes each `.c' file as a separate argument to Emacs, so that Emacs
visits each file (Note: Visiting.).

   Here is an advanced example that assumes you have a Lisp program file
called `hack-c-program.el' which, when loaded, performs some useful
operation on the current buffer, expected to be a C program.

     emacs -batch foo.c -l hack-c-program -f save-buffer -kill > log

Here Emacs is told to visit `foo.c', load `hack-c-program.el' (which
makes changes in the visited file), save `foo.c' (note that
`save-buffer' is the function that `C-x C-s' is bound to), and then
exit to the shell from which the command was executed.  `-batch'
guarantees there will be no problem redirecting output to `log',
because Emacs will not assume that it has a display terminal to work
with.

Command Line Arguments (for Lucid Emacs Under X)
------------------------------------------------

   If you are running Lucid Emacs under X, a number of options are
available to control color, border, and window title and icon name:

`-title TITLE'
`-wn TITLE'
`-T TITLE'
     Use TITLE as the window title. This sets the `screen-title-format'
     variable, which controls the title of the X window corresponding
     to the selected screen.  This is the same format as
     `mode-line-format'.

`-iconname TITLE'
`-in TITLE'
     Use TITLE as the icon name. This sets the
     `screen-icon-title-format' variable, which controls the title of
     the icon corresponding to the selected screen.

`-mc COLOR'
     Use COLOR as the mouse color.

`-cr COLOR'
     Use COLOR as the text-cursor foreground color.

   In addition, Lucid Emacs allows you to use a number of standard Xt
command line arguments.

`-background COLOR'
`-bg COLOR'
     Use COLOR as the background color.

`-bordercolor COLOR'
`-bd COLOR'
     Use COLOR as the border color.

`-borderwidth WIDTH'
`-bw WIDTH'
     Use WIDTH as the border width.

`-display DISPLAY'
`-d DISPLAY'
     When running under the X window system, create the window
     containing the Emacs screen on the display named DISPLAY.

`-foreground COLOR'
`-fg COLOR'
     Use COLOR as the foreground color.

`-font NAME'
`-fn NAME'
     Use NAME as the default font.

`-geometry SPEC'
`-geom SPEC'
`-g SPEC'
     Use the geometry (window size and/or position) specified by SPEC.

`-iconic'
     Start up iconified.

`-rv'
     Bring up Emacs in reverse video.

`-NAME'
     Use the resource manager resources specified by NAME.  The default
     is to use the name of the program (`argv[0]') as the resource
     manager name.

`-xrm'
     Read something into the resource database for this invocation of
     Emacs only.


automatically generated by info2www