[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can use command-line arguments to request various actions when you start Emacs. Since you do not need to start Emacs more than once per day, and will often leave your Emacs session running longer than that, command-line arguments are hardly ever used. As a practical matter, it is best to avoid making the habit of using them, since this habit would encourage you to kill and restart Emacs unnecessarily often. These options exist for two reasons: to be compatible with other editors (for invocation by other programs) and to enable shell scripts to run specific Lisp programs.
This section describes how Emacs processes command-line arguments, and how you can customize them.
t
once the command line has been
processed.
If you redump Emacs by calling dump-emacs
, you may wish to set
this variable to nil
first in order to cause the new dumped Emacs
to process its new command-line arguments.
A command-line option is an argument on the command line, which has the form:
-option |
The elements of the command-switch-alist
look like this:
(option . handler-function) |
The CAR, option, is a string, the name of a command-line option (not including the initial hyphen). The handler-function is called to handle option, and receives the option name as its sole argument.
In some cases, the option is followed in the command line by an
argument. In these cases, the handler-function can find all the
remaining command-line arguments in the variable
command-line-args-left
. (The entire list of command-line
arguments is in command-line-args
.)
The command-line arguments are parsed by the command-line-1
function in the `startup.el' file. See also section `Command Line Switches and Arguments' in The GNU Emacs Manual.
nil
value.
These functions are called with no arguments. They can access the
command-line argument under consideration through the variable
argi
, which is bound temporarily at this point. The remaining
arguments (not including the current one) are in the variable
command-line-args-left
.
When a function recognizes and processes the argument in argi
, it
should return a non-nil
value to say it has dealt with that
argument. If it has also dealt with some of the following arguments, it
can indicate that by deleting them from command-line-args-left
.
If all of these functions return nil
, then the argument is used
as a file name to visit.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |