Initial git import
[sxemacs] / info / sxemacs / 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   SXEmacs 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 SXEmacs 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 SXEmacs 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
32 are running SXEmacs under the X window system, a number of standard Xt
33 command line arguments are available, as well as a few X parameters
34 that are SXEmacs-specific.
35
36   Options with long names with a single initial hyphen are also
37 recognized with the GNU double initial hyphen syntax.  (The reverse
38 is not true.)
39
40 The following subsections list:
41 @itemize @bullet
42 @item 
43 Command line arguments that you can always use
44 @item 
45 Command line arguments that have to appear at the beginning of the
46 argument list
47 @item
48 Command line arguments that are only relevant if you are running SXEmacs
49 under X
50 @end itemize
51
52 @subsection Command Line Arguments for Any Position
53  Command line arguments are processed in the order they appear on the
54 command line; however, certain arguments (the ones in the
55 second table) must be at the front of the list if they are used.
56
57   Here are the arguments allowed:
58
59 @table @samp
60 @item @var{file}
61 Visit @var{file} using @code{find-file}.  @xref{Visiting}.
62
63 @item +@var{linenum} @var{file}
64 Visit @var{file} using @code{find-file}, then go to line number
65 @var{linenum} in it.
66
67 @item -load @var{file}
68 @itemx -l @var{file}
69 Load a file @var{file} of Lisp code with the function @code{load}.
70 @xref{Lisp Libraries}.
71
72 @item -funcall @var{function}
73 @itemx -f @var{function}
74 Call Lisp function @var{function} with no arguments.
75
76 @item -eval @var{function}
77 Interpret the next argument as a Lisp expression, and evaluate it.
78 You must be very careful of the shell quoting here.
79
80 @item -insert @var{file}
81 @itemx -i @var{file}
82 Insert the contents of @var{file} into the current buffer.  This is like
83 what @kbd{M-x insert-buffer} does; @xref{Misc File Ops}.
84
85 @item -kill
86 Exit from Emacs without asking for confirmation.  Always the last
87 argument processed, no matter where it appears in the command line.
88
89 @item -version
90 @itemx -V
91 Prints version information.  This implies @samp{-batch}.
92
93 @example
94 % sxemacs -version
95 SXEmacs: steve@@sxemacs.org--2006/sxemacs--main--22.1.4--patch-79,
96 built Sun Apr  9 05:36:50 2006 on bastard 
97 @end example
98
99 @item -help
100 Prints a summary of command-line options and then exits.
101 @end table
102
103 @subsection Command Line Arguments (Beginning of Line Only)
104   The following arguments are recognized only at the beginning of the
105 command line.  If more than one of them appears, they must appear in the
106 order in which they appear in this table.
107
108 @table @samp
109 @item --show-dump-id
110 @itemx -sd
111 Print the ID for the new portable dumper's dump file on the terminal and
112 exit.  (Prints an error message and exits if SXEmacs was not configured
113 @samp{--pdump}.)
114
115 @item --no-dump-file
116 @itemx -nd
117 Don't load the dump file.  Roughly equivalent to old temacs.  (Ignored if
118 SXEmacs was not configured @samp{--pdump}.)
119
120 @item --terminal @var{file}
121 @itemx -t @var{file}
122 Use @var{file} instead of the terminal for input and output.  This
123 implies the @samp{-nw} option, documented below.
124
125 @cindex batch mode
126 @item -batch
127 Run Emacs in @dfn{batch mode}, which means that the text being edited is
128 not displayed and the standard Unix interrupt characters such as
129 @kbd{C-z} and @kbd{C-c} continue to have their normal effect.  Emacs in
130 batch mode outputs to @code{stderr} only what would normally be printed
131 in the echo area under program control.
132
133 Batch mode is used for running programs written in Emacs Lisp from shell
134 scripts, makefiles, and so on.  Normally the @samp{-l} switch or
135 @samp{-f} switch will be used as well, to invoke a Lisp program to do
136 the batch processing.
137
138 @samp{-batch} implies @samp{-q} (do not load an init file).  It also
139 causes Emacs to kill itself after all command switches have been
140 processed.  In addition, auto-saving is not done except in buffers for
141 which it has been explicitly requested.
142
143 @item --no-windows
144 @itemx -nw
145 Start up SXEmacs in TTY mode (using the TTY SXEmacs was started from),
146 rather than trying to connect to an X display.  Note that this happens
147 automatically if the @samp{DISPLAY} environment variable is not set.
148
149 @item --color-terminal
150 @itemx -ct
151 Tells SXEmacs to assume that any TTY frame should be colorized even
152 when the color support was not detected. The color support is of
153 the 8 color ANSI terminals. If color capabilities of the terminal
154 are detected those more accurate settings are used.
155
156 @item -debug-init
157 Enter the debugger if an error in the init file occurs.
158
159 @item -debug-paths
160 Displays information on how SXEmacs constructs the various paths into its
161 hierarchy on startup.  (See also @pxref{Startup Paths}.)
162
163 @item -unmapped
164 Do not map the initial frame.  This is useful if you want to start up
165 SXEmacs as a server (e.g. for gnuserv screens or external client widgets).
166
167 @item -no-init-file
168 @itemx -q
169 Do not load your Emacs init file.  @xref{Init File}.
170
171 @item -no-site-file
172 Do not load the site-specific init file @file{lisp/site-start.el}.
173
174 @item -no-autoloads
175 Do not load global symbol files (@file{auto-autoloads}) at startup.
176 This implies @samp{-vanilla}. 
177
178 @item -no-early-packages
179 Do not process early packages.  (For more information on startup issues
180 concerning the package system, @xref{Startup Paths}.)
181
182 @item -vanilla
183 This is equivalent to @samp{-q -no-site-file -no-early-packages}.
184
185 @item -user-init-file @var{file}
186 Load @var{file} as your Emacs init file instead of
187 @file{~/.sxemacs/init.el}.
188
189 @item -user-init-directory @var{directory}
190 Use @var{directory} as the location of your early package hierarchies
191 and the various user-specific initialization files.
192
193 @item -user @var{user}
194 @itemx -u @var{user}
195 Equivalent to @samp{-user-init-file ~@var{user}/.sxemacs/init.el
196 -user-init-directory ~@var{user}/.sxemacs}, or @samp{-user-init-file
197 ~@var{user}/.emacs -user-init-directory ~@var{user}/.sxemacs}, whichever
198 init file comes first.  @xref{Init File}.
199
200 @end table
201
202 @vindex command-line-args
203   Note that the init file can get access to the command line argument
204 values as the elements of a list in the variable
205 @code{command-line-args}.  (The arguments in the second table above will
206 already have been processed and will not be in the list.)  The init file
207 can override the normal processing of the other arguments by setting
208 this variable.
209
210   One way to use command switches is to visit many files automatically:
211
212 @example
213 sxemacs *.c
214 @end example
215
216 @noindent
217 passes each @code{.c} file as a separate argument to Emacs, so that
218 Emacs visits each file (@pxref{Visiting}).
219
220   Here is an advanced example that assumes you have a Lisp program file
221 called @file{hack-c-program.el} which, when loaded, performs some useful
222 operation on the current buffer, expected to be a C program.
223
224 @example
225 sxemacs -batch foo.c -l hack-c-program -f save-buffer -kill > log
226 @end example
227
228 @noindent
229 Here Emacs is told to visit @file{foo.c}, load @file{hack-c-program.el}
230 (which makes changes in the visited file), save @file{foo.c} (note that
231 @code{save-buffer} is the function that @kbd{C-x C-s} is bound to), and
232 then exit to the shell from which the command was executed.  @samp{-batch}
233 guarantees there will be no problem redirecting output to @file{log},
234 because Emacs will not assume that it has a display terminal to work
235 with.
236
237 @subsection Command Line Arguments (for SXEmacs Under X)
238 @vindex frame-title-format
239 @vindex frame-icon-title-format
240 If you are running SXEmacs under X, a number of options are
241 available to control color, border, and window title and icon name:
242
243 @table @samp
244 @item -title @var{title}
245 @itemx -wn @var{title}
246 @itemx -T @var{title}
247 Use @var{title} as the window title. This sets the
248 @code{frame-title-format} variable, which controls the title of the X
249 window corresponding to the selected frame.  This is the same format as
250 @code{mode-line-format}.
251
252 @item -iconname @var{title}
253 @itemx -in @var{title}
254 Use @var{title} as the icon name. This sets the
255 @code{frame-icon-title-format} variable, which controls the title of
256 the icon corresponding to the selected frame.
257
258 @item -mc @var{color}
259 Use @var{color} as the mouse color.
260
261 @item -cr @var{color}
262 Use @var{color} as the text-cursor foreground color.
263
264 @item -private
265 Install a private colormap for SXEmacs.
266 @end table
267
268 In addition, SXEmacs allows you to use a number of standard Xt
269 command line arguments. 
270
271 @table @samp
272
273 @item -background @var{color}
274 @itemx -bg @var{color}
275 Use @var{color} as the background color.
276
277 @item -bordercolor @var{color}
278 @itemx -bd @var{color}
279 Use @var{color} as the border color.
280
281 @item -borderwidth @var{width}
282 @itemx -bw @var{width}
283 Use @var{width} as the border width.
284
285 @item -display @var{display}
286 @itemx -d @var{display}
287 When running under the X window system, create the window containing the
288 Emacs frame on the display named @var{display}.
289
290 @item -foreground @var{color}
291 @itemx -fg @var{color}
292 Use @var{color} as the foreground color.
293
294 @item -font @var{name}
295 @itemx -fn @var{name}
296 Use @var{name} as the default font.
297
298 @item -geometry @var{spec}
299 @itemx -geom @var{spec}
300 @itemx -g @var{spec}
301 Use the geometry (window size and/or position) specified by @var{spec}.
302
303 @item -iconic
304 Start up iconified.
305
306 @item -rv
307 Bring up Emacs in reverse video.
308
309 @item -name @var{name}
310 Use the resource manager resources specified by @var{name}.
311 The default is to use the name of the program (@code{argv[0]}) as
312 the resource manager name.
313
314 @item -xrm
315 Read something into the resource database for this invocation of Emacs only.
316
317 @end table