fe78398c576e7683bdafcdbd0bd87d1f7198b767
[chise/xemacs-chise.git.1] / man / xemacs / cmdargs.texi
1
2 @node Command Switches, Startup Paths, Exiting, Top
3 @section Command Line Switches and Arguments
4 @cindex command line arguments
5 @cindex arguments (from shell)
6
7   XEmacs supports command line arguments you can use to request
8 various actions when invoking Emacs.  The commands are for compatibility
9 with other editors and for sophisticated activities.  If you are using
10 XEmacs under the X window system, you can also use a number of
11 standard Xt command line arguments. Command line arguments are not usually
12 needed for editing with Emacs; new users can skip this section.
13
14 Many editors are designed to be started afresh each time you want to
15 edit.  You start the editor to edit one file; then exit the editor.  The
16 next time you want to edit either another file or the same one, you
17 start the editor again.  Under these circumstances, it makes sense to use a
18 command line argument to say which file to edit.
19
20   The recommended way to use XEmacs is to start it only once, just
21 after you log in, and do all your editing in the same Emacs process.
22 Each time you want to edit a file, you visit it using the existing
23 Emacs.  Emacs creates a new buffer for each file, and (unless you kill
24 some of the buffers) Emacs eventually has many files in it ready for
25 editing.  Usually you do not kill the Emacs process until you are about
26 to log out.  Since you usually read files by typing commands to Emacs,
27 command line arguments for specifying a file when Emacs is started are seldom
28 needed.
29
30   Emacs accepts command-line arguments that specify files to visit,
31 functions to call, and other activities and operating modes.  If you are
32 running XEmacs under the X window system, a number of standard
33 Xt command line arguments are available as well. 
34
35 The following subsections list:
36 @itemize @bullet
37 @item 
38 Command line arguments that you can always use
39 @item 
40 Command line arguments that have to appear at the beginning of the
41 argument list
42 @item
43 Command line arguments that are only relevant if you are running XEmacs
44 under X
45 @end itemize
46
47 @subsection Command Line Arguments for Any Position
48  Command line arguments are processed in the order they appear on the
49 command line; however, certain arguments (the ones in the
50 second table) must be at the front of the list if they are used.
51
52   Here are the arguments allowed:
53
54 @table @samp
55 @item @var{file}
56 Visit @var{file} using @code{find-file}.  @xref{Visiting}.
57
58 @item +@var{linenum} @var{file}
59 Visit @var{file} using @code{find-file}, then go to line number
60 @var{linenum} in it.
61
62 @item -load @var{file}
63 @itemx -l @var{file}
64 Load a file @var{file} of Lisp code with the function @code{load}.
65 @xref{Lisp Libraries}.
66
67 @item -funcall @var{function}
68 @itemx -f @var{function}
69 Call Lisp function @var{function} with no arguments.
70
71 @item -eval @var{function}
72 Interpret the next argument as a Lisp expression, and evaluate it.
73 You must be very careful of the shell quoting here.
74
75 @item -insert @var{file}
76 @itemx -i @var{file}
77 Insert the contents of @var{file} into the current buffer.  This is like
78 what @kbd{M-x insert-buffer} does; @xref{Misc File Ops}.
79
80 @item -kill
81 Exit from Emacs without asking for confirmation.
82
83 @item -version
84 @itemx -V
85 Prints version information.  This implies @samp{-batch}.
86
87 @example
88 % xemacs -version
89 XEmacs 19.13 of Mon Aug 21 1995 on willow (usg-unix-v) [formerly Lucid Emacs]
90 @end example
91
92 @item -help
93 Prints a summary of command-line options and then exits.
94 @end table
95
96 @subsection Command Line Arguments (Beginning of Line Only)
97   The following arguments are recognized only at the beginning of the
98 command line.  If more than one of them appears, they must appear in the
99 order in which they appear in this table.
100
101 @table @samp
102 @item -t @var{file}
103 Use @var{file} instead of the terminal for input and output.  This
104 implies the @samp{-nw} option, documented below.
105
106 @cindex batch mode
107 @item -batch
108 Run Emacs in @dfn{batch mode}, which means that the text being edited is
109 not displayed and the standard Unix interrupt characters such as
110 @kbd{C-z} and @kbd{C-c} continue to have their normal effect.  Emacs in
111 batch mode outputs to @code{stderr} only what would normally be printed
112 in the echo area under program control.
113
114 Batch mode is used for running programs written in Emacs Lisp from shell
115 scripts, makefiles, and so on.  Normally the @samp{-l} switch or
116 @samp{-f} switch will be used as well, to invoke a Lisp program to do
117 the batch processing.
118
119 @samp{-batch} implies @samp{-q} (do not load an init file).  It also
120 causes Emacs to kill itself after all command switches have been
121 processed.  In addition, auto-saving is not done except in buffers for
122 which it has been explicitly requested.
123
124 @item -nw
125 Start up XEmacs in TTY mode (using the TTY XEmacs was started from),
126 rather than trying to connect to an X display.  Note that this happens
127 automatically if the @samp{DISPLAY} environment variable is not set.
128
129 @item -debug-init
130 Enter the debugger if an error in the init file occurs.
131
132 @item -debug-paths
133 Displays information on how XEmacs constructs the various paths into its
134 hierarchy on startup.  (See also @pxref{Startup Paths}.)
135
136 @item -unmapped
137 Do not map the initial frame.  This is useful if you want to start up
138 XEmacs as a server (e.g. for gnuserv screens or external client widgets).
139
140 @item -no-init-file
141 @itemx -q
142 Do not load your Emacs init file @file{~/.emacs}.
143
144 @item -no-site-file
145 Do not load the site-specific init file @file{lisp/site-start.el}.
146
147 @item -no-autoloads
148 Do not load global symbol files (@file{auto-autoloads}) at startup.
149 This implies @samp{-vanilla}. 
150
151 @item -no-early-packages
152 Do not process early packages.  (For more information on startup issues
153 concerning the package system, @xref{Startup Paths}.)
154
155 @item -vanilla
156 This is equivalent to @samp{-q -no-site-file -no-early-packages}.
157
158 @item -user-init-file @var{file}
159 Load @var{file} as your Emacs init file instead of @file{~/.emacs}.
160
161 @item -user-init-directory @var{directory}
162 Use @var{directory} as the location of your early package hierarchies
163 and the various user-specific initialization files.
164
165 @item -user @var{user}
166 @itemx -u @var{user}
167 Equivalent to
168 @samp{-user-init-file ~@var{user}/.emacs -user-init-directory ~@var{user}/.xemacs}.
169
170
171 @end table
172
173 @vindex command-line-args
174   Note that the init file can get access to the command line argument
175 values as the elements of a list in the variable
176 @code{command-line-args}.  (The arguments in the second table above will
177 already have been processed and will not be in the list.)  The init file
178 can override the normal processing of the other arguments by setting
179 this variable.
180
181   One way to use command switches is to visit many files automatically:
182
183 @example
184 xemacs *.c
185 @end example
186
187 @noindent
188 passes each @code{.c} file as a separate argument to Emacs, so that
189 Emacs visits each file (@pxref{Visiting}).
190
191   Here is an advanced example that assumes you have a Lisp program file
192 called @file{hack-c-program.el} which, when loaded, performs some useful
193 operation on the current buffer, expected to be a C program.
194
195 @example
196 xemacs -batch foo.c -l hack-c-program -f save-buffer -kill > log
197 @end example
198
199 @noindent
200 Here Emacs is told to visit @file{foo.c}, load @file{hack-c-program.el}
201 (which makes changes in the visited file), save @file{foo.c} (note that
202 @code{save-buffer} is the function that @kbd{C-x C-s} is bound to), and
203 then exit to the shell from which the command was executed.  @samp{-batch}
204 guarantees there will be no problem redirecting output to @file{log},
205 because Emacs will not assume that it has a display terminal to work
206 with.
207
208 @subsection Command Line Arguments (for XEmacs Under X)
209 @vindex frame-title-format
210 @vindex frame-icon-title-format
211 If you are running XEmacs under X, a number of options are
212 available to control color, border, and window title and icon name:
213
214 @table @samp
215 @item -title @var{title}
216 @itemx -wn @var{title}
217 @itemx -T @var{title}
218 Use @var{title} as the window title. This sets the
219 @code{frame-title-format} variable, which controls the title of the X
220 window corresponding to the selected frame.  This is the same format as
221 @code{mode-line-format}.
222
223 @item -iconname @var{title}
224 @itemx -in @var{title}
225 Use @var{title} as the icon name. This sets the
226 @code{frame-icon-title-format} variable, which controls the title of
227 the icon corresponding to the selected frame.
228
229 @item -mc @var{color}
230 Use @var{color} as the mouse color.
231
232 @item -cr @var{color}
233 Use @var{color} as the text-cursor foreground color.
234
235 @item -private
236 Install a private colormap for XEmacs.
237 @end table
238
239 In addition, XEmacs allows you to use a number of standard Xt
240 command line arguments. 
241
242 @table @samp
243
244 @item -background @var{color}
245 @itemx -bg @var{color}
246 Use @var{color} as the background color.
247
248 @item -bordercolor @var{color}
249 @itemx -bd @var{color}
250 Use @var{color} as the border color.
251
252 @item -borderwidth @var{width}
253 @itemx -bw @var{width}
254 Use @var{width} as the border width.
255
256 @item -display @var{display}
257 @itemx -d @var{display}
258 When running under the X window system, create the window containing the
259 Emacs frame on the display named @var{display}.
260
261 @item -foreground @var{color}
262 @itemx -fg @var{color}
263 Use @var{color} as the foreground color.
264
265 @item -font @var{name}
266 @itemx -fn @var{name}
267 Use @var{name} as the default font.
268
269 @item -geometry @var{spec}
270 @itemx -geom @var{spec}
271 @itemx -g @var{spec}
272 Use the geometry (window size and/or position) specified by @var{spec}.
273
274 @item -iconic
275 Start up iconified.
276
277 @item -rv
278 Bring up Emacs in reverse video.
279
280 @item -name @var{name}
281 Use the resource manager resources specified by @var{name}.
282 The default is to use the name of the program (@code{argv[0]}) as
283 the resource manager name.
284
285 @item -xrm
286 Read something into the resource database for this invocation of Emacs only.
287
288 @end table