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