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