[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Entering and Exiting Emacs

The usual way to invoke XEmacs is to type xemacs RET at the shell. XEmacs clears the screen and then displays an initial advisory message and copyright notice. You can begin typing XEmacs commands immediately afterward.

Some operating systems insist on discarding all type-ahead when XEmacs starts up; they give XEmacs no way to prevent this. Therefore, it is advisable to wait until XEmacs clears the screen before typing your first editing command.

If you run XEmacs from a shell window under the X Window System, run it in the background with `xemacs&'. This way, XEmacs does not tie up the shell window, so you can use that to run other shell commands while XEmacs operates its own X windows. You can begin typing XEmacs commands as soon as you direct your keyboard input to the XEmacs frame.

Before Emacs reads the first command, you have not had a chance to give a command to specify a file to edit. Since Emacs must always have a current buffer for editing, it presents a buffer, by default, a buffer named `*scratch*'. The buffer is in Lisp Interaction mode; you can use it to type Lisp expressions and evaluate them, or you can ignore that capability and simply doodle. (Which is where the name comes from; a "scratch pad" is a set of paper for doodling on, something not necessarily clear to all the English-speakers who read this.)

You can specify a different major mode for this buffer by setting the variable initial-major-mode in your init file. See section 27.7 The Init File.

It is possible to specify files to be visited, Lisp files to be loaded, and functions to be called, by giving Emacs arguments in the shell command line. See section 3.2 Command Line Switches and Arguments. But we don't recommend doing this. The feature exists mainly for compatibility with other editors.

Many other editors are designed to be started afresh each time you want to edit. You edit one file and then exit the editor. The next time you want to edit either another file or the same one, you must run the editor again. With these editors, it makes sense to use a command-line argument to say which file to edit.

But starting a new Emacs each time you want to edit a different file does not make sense. For one thing, this would be annoyingly slow. For another, this would fail to take advantage of Emacs's ability to visit more than one file in a single editing session. And it would lose the other accumulated context, such as registers, undo history, and the mark ring.

The recommended way to use XEmacs is to start it only once, just after you log in, and do all your editing in the same Emacs session. Each time you want to edit a different file, you visit it with the existing Emacs, which eventually comes to have many files in it ready for editing. Usually you do not kill the Emacs until you are about to log out. See section 14. File Handling, for more information on visiting more than one file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Exiting Emacs

There are two commands for exiting Emacs because there are two kinds of exiting: suspending Emacs and killing Emacs.

Suspending means stopping Emacs temporarily and returning control to its parent process (usually a shell), allowing you to resume editing later in the same Emacs job, with the same buffers, same kill ring, same undo history, and so on. This is the usual way to exit.

Killing Emacs means destroying the Emacs job. You can run Emacs again later, but you will get a fresh Emacs; there is no way to resume the same editing session after it has been killed.

C-z
Suspend Emacs or iconify a frame (suspend-emacs-or-iconify-frame). If used under the X window system, shrink the X window containing the Emacs frame to an icon (see below).
C-x C-c
Kill Emacs (save-buffers-kill-emacs).

If you use XEmacs under the X window system, C-z shrinks the X window containing the Emacs frame to an icon. The Emacs process is stopped temporarily, and control is returned to the window manager. If more than one frame is associated with the Emacs process, only the frame from which you used C-z is iconified.

To activate the "suspended" Emacs, use the appropriate window manager mouse gestures. Usually left-clicking on the icon reactivates and reopens the X window containing the Emacs frame, but the window manager you use determines what exactly happens. To actually kill the Emacs process, use C-x C-c or the Exit XEmacs item on the File menu.

To suspend Emacs, type C-z (suspend-emacs). This takes you back to the shell from which you invoked Emacs. You can resume Emacs with the shell command `%xemacs' in most common shells.

On systems that do not support suspending programs, C-z starts an inferior shell that communicates directly with the terminal. Emacs waits until you exit the subshell. (The way to do that is probably with C-d or `exit', but it depends on which shell you use.) The only way on these systems to get back to the shell from which Emacs was run (to log out, for example) is to kill Emacs.

Suspending also fails if you run Emacs under a shell that doesn't support suspending programs, even if the system itself does support it. In such a case, you can set the variable cannot-suspend to a non-nil value to force C-z to start an inferior shell. (One might also describe Emacs's parent shell as "inferior" for failing to support job control properly, but that is a matter of taste.)

When Emacs communicates directly with an X server and creates its own dedicated X windows, C-z has a different meaning. Suspending an applications that uses its own X windows is not meaningful or useful. Instead, C-z runs the command iconify-or-deiconify-frame, which temporarily closes up the selected Emacs frame. The way to get back to a shell window is with the window manager.

To kill Emacs, type C-x C-c (save-buffers-kill-emacs). A two-character key is used for this to make it harder to type. Selecting the Exit XEmacs option of the File menu is an alternate way of issuing the command.

Unless a numeric argument is used, this command first offers to save any modified file-visiting buffers. If you do not save all buffers, you are asked for reconfirmation with yes before killing Emacs, since any changes not saved will be lost forever. If any subprocesses are still running, C-x C-c asks you to confirm killing them, since killing Emacs will kill the subprocesses immediately.

There is no way to restart an Emacs session once you have killed it. You can, however, arrange for Emacs to record certain session information, such as which files are visited, when you kill it, so that the next time you restart Emacs it will try to visit the same files and so on.

The operating system usually listens for certain special characters whose meaning is to kill or suspend the program you are running. This operating system feature is turned off while you are in Emacs. The meanings of C-z and C-x C-c as keys in Emacs were inspired by the use of C-z and C-c on several operating systems as the characters for stopping or killing a program, but that is their only relationship with the operating system. You can customize these keys to run any commands of your choice (see section 27.5.1 Keymaps).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Command Line Switches and Arguments

XEmacs supports command line arguments you can use to request various actions when invoking Emacs. The commands are for compatibility with other editors and for sophisticated activities. If you are using XEmacs under the X window system, you can also use a number of standard Xt command line arguments. Command line arguments are not usually needed for editing with Emacs; new users can skip this section.

Many editors are designed to be started afresh each time you want to edit. You start the editor to edit one file; then exit the editor. The next time you want to edit either another file or the same one, you start the editor again. Under these circumstances, it makes sense to use a command line argument to say which file to edit.

The recommended way to use XEmacs is to start it only once, just after you log in, and do all your editing in the same Emacs process. Each time you want to edit a file, you visit it using the existing Emacs. Emacs creates a new buffer for each file, and (unless you kill some of the buffers) Emacs eventually has many files in it ready for editing. Usually you do not kill the Emacs process until you are about to log out. Since you usually read files by typing commands to Emacs, command line arguments for specifying a file when Emacs is started are seldom needed.

Emacs accepts command-line arguments that specify files to visit, functions to call, and other activities and operating modes. If you are running XEmacs under the X window system, a number of standard Xt command line arguments are available, as well as a few X parameters that are XEmacs-specific.

Options with long names with a single initial hyphen are also recognized with the GNU double initial hyphen syntax. (The reverse is not true.)

The following subsections list:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.1 Command Line Arguments for Any Position

Command line arguments are processed in the order they appear on the command line; however, certain arguments (the ones in the second table) must be at the front of the list if they are used.

Here are the arguments allowed:

`file'
Visit file using find-file. See section 14.2 Visiting Files.

`+linenum file'
Visit file using find-file, then go to line number linenum in it.

`-load file'
`-l file'
Load a file file of Lisp code with the function load. See section 22.3 Libraries of Lisp Code for Emacs.

`-funcall function'
`-f function'
Call Lisp function function with no arguments.

`-eval function'
Interpret the next argument as a Lisp expression, and evaluate it. You must be very careful of the shell quoting here.

`-insert file'
`-i file'
Insert the contents of file into the current buffer. This is like what M-x insert-buffer does; See section 14.10 Miscellaneous File Operations.

`-kill'
Exit from Emacs without asking for confirmation. Always the last argument processed, no matter where it appears in the command line.

`-version'
`-V'
Prints version information. This implies `-batch'.

 
% xemacs -version
XEmacs 19.13 of Mon Aug 21 1995 on willow (usg-unix-v) [formerly Lucid Emacs]

`-help'
Prints a summary of command-line options and then exits.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.2 Command Line Arguments (Beginning of Line Only)

The following arguments are recognized only at the beginning of the command line. If more than one of them appears, they must appear in the order in which they appear in this table.

`--show-dump-id'
`-sd'
Print the ID for the new portable dumper's dump file on the terminal and exit. (Prints an error message and exits if XEmacs was not configured `--pdump'.)

`--no-dump-file'
`-nd'
Don't load the dump file. Roughly equivalent to old temacs. (Ignored if XEmacs was not configured `--pdump'.)

`--terminal file'
`-t file'
Use file instead of the terminal for input and output. This implies the `-nw' option, documented below.

`-batch'
Run Emacs in batch mode, which means that the text being edited is not displayed and the standard Unix interrupt characters such as C-z and C-c continue to have their normal effect. Emacs in batch mode outputs to stderr only what would normally be printed in the echo area under program control.

Batch mode is used for running programs written in Emacs Lisp from shell scripts, makefiles, and so on. Normally the `-l' switch or `-f' switch will be used as well, to invoke a Lisp program to do the batch processing.

`-batch' implies `-q' (do not load an init file). It also causes Emacs to kill itself after all command switches have been processed. In addition, auto-saving is not done except in buffers for which it has been explicitly requested.

`--no-windows'
`-nw'
Start up XEmacs in TTY mode (using the TTY XEmacs was started from), rather than trying to connect to an X display. Note that this happens automatically if the `DISPLAY' environment variable is not set.

`-debug-init'
Enter the debugger if an error in the init file occurs.

`-debug-paths'
Displays information on how XEmacs constructs the various paths into its hierarchy on startup. (See also see section 3.3 How XEmacs finds Directories and Files.)

`-unmapped'
Do not map the initial frame. This is useful if you want to start up XEmacs as a server (e.g. for gnuserv screens or external client widgets).

`-no-init-file'
`-q'
Do not load your Emacs init file. See section 27.7 The Init File.

`-no-site-file'
Do not load the site-specific init file `lisp/site-start.el'.

`-no-autoloads'
Do not load global symbol files (`auto-autoloads') at startup. This implies `-vanilla'.

`-no-early-packages'
Do not process early packages. (For more information on startup issues concerning the package system, See section 3.3 How XEmacs finds Directories and Files.)

`-script file'
`--script file'
Load file as a (compiled or interpreted) Lisp file; do not load any window-system or TTY code, do not load the user init file, the site file, or the early packages. This is comparable to running `xemacs' `-batch' `-l' file.

You can also specify this flag implicitly by calling the XEmacs binary with a value for `argv[0]' of `xemacs-script', normally by means of a symbolic link. On a POSIX system, this means that adding the line:

 
#!/usr/bin/env xemacs-script

at the start of an XEmacs Lisp file, and changing that file's permissions to executable, creates a script that can be invoked by typing the path to the file. XEmacs has logic to ignore the #! line at the start of the script, so that won't cause an error.

`-vanilla'
This is equivalent to `-q -no-site-file -no-early-packages'.

`-user-init-file file'
Load file as your Emacs init file instead of `~/.xemacs/init.el'/`~/.emacs'.

`-user-init-directory directory'
Use directory as the location of your early package hierarchies and the various user-specific initialization files.

`-user user'
`-u user'
Equivalent to `-user-init-file ~user/.xemacs/init.el -user-init-directory ~user/.xemacs', or `-user-init-file ~user/.emacs -user-init-directory ~user/.xemacs', whichever init file comes first. See section 27.7 The Init File.

Note that the init file can get access to the command line argument values as the elements of a list in the variable command-line-args. (The arguments in the second table above will already have been processed and will not be in the list.) The init file can override the normal processing of the other arguments by setting this variable.

One way to use command switches is to visit many files automatically:

 
xemacs *.c

passes each .c file as a separate argument to Emacs, so that Emacs visits each file (see section 14.2 Visiting Files).

Here is an advanced example that assumes you have a Lisp program file called `hack-c-program.el' which, when loaded, performs some useful operation on the current buffer, expected to be a C program.

 
xemacs -batch foo.c -l hack-c-program -f save-buffer -kill > log

Here Emacs is told to visit `foo.c', load `hack-c-program.el' (which makes changes in the visited file), save `foo.c' (note that save-buffer is the function that C-x C-s is bound to), and then exit to the shell from which the command was executed. `-batch' guarantees there will be no problem redirecting output to `log', because Emacs will not assume that it has a display terminal to work with.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.3 Command Line Arguments (for XEmacs Under X)

If you are running XEmacs under X, a number of options are available to control color, border, and window title and icon name:

`-title title'
`-wn title'
`-T title'
Use title as the window title. This sets the frame-title-format variable, which controls the title of the X window corresponding to the selected frame. This is the same format as mode-line-format.

`-iconname title'
`-in title'
Use title as the icon name. This sets the frame-icon-title-format variable, which controls the title of the icon corresponding to the selected frame.

`-mc color'
Use color as the mouse color.

`-cr color'
Use color as the text-cursor foreground color.

`-private'
Install a private colormap for XEmacs.

In addition, XEmacs allows you to use a number of standard Xt command line arguments.

`-background color'
`-bg color'
Use color as the background color.

`-bordercolor color'
`-bd color'
Use color as the border color.

`-borderwidth width'
`-bw width'
Use width as the border width.

`-display display'
`-d display'
When running under the X window system, create the window containing the Emacs frame on the display named display.

`-foreground color'
`-fg color'
Use color as the foreground color.

`-font name'
`-fn name'
Use name as the default font.

`-geometry spec'
`-geom spec'
`-g spec'
Use the geometry (window size and/or position) specified by spec.

`-iconic'
Start up iconified.

`-rv'
Bring up Emacs in reverse video.

`-name name'
Use the resource manager resources specified by name. The default is to use the name of the program (argv[0]) as the resource manager name.

`-xrm'
Read something into the resource database for this invocation of Emacs only.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 How XEmacs finds Directories and Files

XEmacs deals with a multitude of files during operation. These files are spread over many directories, and XEmacs determines the location of most of these directories at startup and organizes them into various paths. (A path, for the purposes of this section, is simply a list of directories which XEmacs searches successively in order to locate a file.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.1 XEmacs Directory Hierarchies

Many of the files XEmacs looks for are located within the XEmacs installation itself. However, there are several views of what actually constitutes the "XEmacs installation": XEmacs may be run from the compilation directory, it may be installed into arbitrary directories, spread over several directories unrelated to each other. Moreover, it may subsequently be moved to a different place. (This last case is not as uncommon as it sounds. Binary kits work this way.) Consequently, XEmacs has quite complex procedures in place to find directories, no matter where they may be hidden.

XEmacs will always respect directory options passed to configure. However, if it cannot locate a directory at the configured place, it will initiate a search for the directory in any of a number of hierarchies rooted under a directory which XEmacs assumes contain parts of the XEmacs installation; it may locate several such hierarchies and search across them. (Typically, there are just one or two hierarchies: the hierarchy where XEmacs was or will be installed, and the one where it is being built.) Such a directory containing a hierarchy is called a root. Whenever this section refers to a directory using the shorthand <root>, it means that XEmacs searches for it under all hierarchies XEmacs was able to scrounge up. In a running XEmacs, the hierarchy roots are stored in the variable emacs-roots.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.2 Package Hierarchies

Many relevant directories and files XEmacs uses are actually not part of the core installation. They are part of any of the many packages usually installed on top of an XEmacs installation. (See section 22.8 Packages.) Hence, they play a prominent role in the various paths XEmacs sets up.

XEmacs locates packages in any of a number of package hierarchies. Package hierarchies fall into three groups: early, late, and last, according to the relative location at which they show up in the various XEmacs paths. Early package hierarchies are at the very front, late ones somewhere in the middle, and last hierarchies are (you guessed it) last.

By default, XEmacs expects an early package hierarchy in the subdirectory `.xemacs/xemacs-packages' of the user's home directory.

Moreover, XEmacs expects late hierarchies in the subdirectories `site-packages', `mule-packages', and `xemacs-packages' (in that order) of the `<root>/share/xemacs' subdirectory of one of the installation hierarchies. (If you run in-place, these are direct subdirectories of the build directory.) Furthermore, XEmacs will also search these subdirectories in the `<root>/share/xemacs-<VERSION>' subdirectory and prefer directories found there.

By default, XEmacs does not have a pre-configured last package hierarchy. Last hierarchies are primarily for using package hierarchies of outdated versions of XEmacs as a fallback option. For example, it is possible to run XEmacs 21 with the 20.4 package hierarchy as a last hierarchy.

It is possible to specify at configure-time the location of the various package directories with the --with-user-packages (an alias for `--with-early-packages'), --with-system-packages (an alias for `--with-late-packages'), and --with-legacy-packages (an alias for `--with-last-packages') options to configure. At run time, the package directories may also be specified via the EMACSEARLYPACKAGES, EMACSLATEPACKAGES, and EMACSLASTPACKAGES environment variables.

An XEmacs package hierarchy is laid out just like a normal installed XEmacs directory. It may have `lisp', `etc', `info', and `lib-src' subdirectories. (The `lib-src' subdirectory contains architecture-independent general-purpose scripts interpreted by the shell or Perl. Java is also being widely used, but Java programs are generally found under `etc', because they are specific to particular packages such as `JDE' and `xslt'.) XEmacs adds these at appropriate places within the various system-wide paths.

There may be any number of package hierarchy directories.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.3 Directories and Paths

Here is a list of the various directories and paths XEmacs tries to locate during startup. XEmacs distinguishes between directories and paths specific to version, site, and architecture when looking for them.

version-specific
directories (such as `etc', the `info' of the installed XEmacs and its Lisp files in `lisp') are specific to the version of XEmacs they belong to and typically reside under `<root>/share/xemacs-<VERSION>'.
site-specific
directories are independent of the version of XEmacs and typically reside under `<root>/share/xemacs'.
architecture-specific
directories are specific both to the version of XEmacs and the architecture it runs on and typically reside under `<root>/lib/xemacs-<VERSION>/<ARCHITECTURE>'.

During installation, all of these directories may also reside directly under `<root>', because that is where they are in the XEmacs tarball.

If XEmacs runs with the -debug-paths option (see section 3.2 Command Line Switches and Arguments), it will print the values of these variables, hopefully aiding in debugging any problems which come up.

lisp-directory
Contains the version-specific location of the Lisp files that come with the core distribution of XEmacs. XEmacs will search it recursively to a depth of 1 when setting up load-path.

load-path
Is where XEmacs searches for XEmacs Lisp files with commands like load-library. It contains the package lisp directories (see further down) and the version-specific core Lisp directories. If the environment variable EMACSLOADPATH is set at startup, its directories are prepended to load-path.

Info-directory-list
Contains the location of info files. (See @xref{(info)}.) It contains the package info directories and the version-specific core documentation. Moreover, XEmacs will add `/usr/info', `/usr/local/info' as well as the directories of the environment variable INFOPATH to Info-directory-list.

exec-directory
Is the directory of architecture-dependent files that come with XEmacs, especially executable programs intended for XEmacs to invoke.

exec-path
Is the path for executables which XEmacs may want to start. It contains the package executable paths as well as exec-directory, and the directories of the environment variables PATH and EMACSPATH.

doc-directory
Is the directory containing the architecture-specific `DOC' file that contains documentation for XEmacs' commands.

data-directory
Is the version-specific directory that contains core data files XEmacs uses. It may be initialized from the EMACSDATA environment variable.

data-directory-list
Is the path where XEmacs looks for data files. It contains package data directories as well as data-directory.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on August, 3 2012 using texi2html