MrEd accepts a number of command-line flags. Under MacOS, a user can specify command-line flags by holding down the Command key while starting MrEd, which provides a dialog for entering the command line. Dragging files onto the MrEd icon in MacOS is equivalent to providing each file's name on the command line preceded by -f, so each file is loaded after MrEd starts. When files are dragged onto MrEd with the Command key pressed, the command line specified in the dialog is appended to the implicit command-line for loading the files.
MrEd accepts the following flags (in addition to the X-specific flags described in X Window System Flags):
Extra arguments following the last flag are put into the Scheme global variable argv as a vector of strings. The name used to start MrEd is put into the global variable program as a string.
Multiple single-letter flags (the ones preceded by a single dash) can
be collapsed into a single flag by concatenating the letters, as long
as the the first flag is not -. The arguments for each flag
are placed after the collapsed flags (in the order of the
flags). For example,
-vfme file expr
and
-v -f file -m -e expr
are equivalent.
The current-library-collection-paths parameter is initialized (as described in Library Collections and MzLib) before any expression or file is evaluated or loaded, unless the -x or --no-lib-path flag is specified.
Unless the -q or --no-init-file flag is specified, a user initialization file is loaded after current-library-collection-paths parameter is initialized and before any other expression or file is evaluated or loaded. The path to the user initialization file is obtained from MzScheme's find-system-path procedure using 'init-file.
Expressions and files are evaluated and loaded in order that they are provided on the command line. The thread that loads the files and evaluates the expression is the main thread. When the main thread terminates (or is killed), the MrEd process exits. The main thread is also the handler thread of the initial eventspace.
After the command-line files and expressions are loaded and evaluated, the main thread calls graphical-read-eval-print-loop, unless the -v, --version, -r, --script, -i, --script-cd flag is specified. The -z or --stdio flag also suppresses the call to graphical-read-eval-print-loop, but it calls read-eval-print-loop, instead. (The other flags, such as -v, have no effect on this call to read-eval-print-loop.)
Evaluating command-line expressions with -f or -v is different from evaluating the same expressions within the window provided by graphical-read-eval-print-loop. The graphical-read-eval-print-loop window creates a new eventspace (and thus a new thread) for evaluating expressions entered into the window. One consequence of this convention is that terminating the evaluation thread (e.g., with (kill-thread (current-thread))) does not cause MrEd to exit, because the evalaution thread is not MrEd's main thread.
In contrast, MzScheme's read-eval-print-loop always evaluates expressions within the thread that calls read-eval-print-loop. Using the -z or --stdio flag calls read-eval-print-loop in the main thread, so (kill-thread (current-thread)) in that case does exit MrEd. Furthermore, the main thread is the handler thread for the initial eventspace; thus, windows created in read-eval-print-loop without changing the eventspace never receive events unless (yield) is called explicitly.