# exit-emacs(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

exit-emacs - Exit MicroEmacs

## SYNOPSIS

n exit-emacs [exitCode]

## DESCRIPTION

Exit MicroEmacs back to the operating system. If no argument n is given and there are any unwritten, changed buffers, the editor prompts the user to discard changes. If an argument is specified then MicroEmacs exits immediately.

The numeric argument is defined as a bit-mask as follows:

`0x01`

Prompting the user before saving any files, writes out all changed buffers to the files they were read from. Saves all changed dictionaries, killing any running commands and exits the editor.

`0x02`

Writes out all changed buffers to the files they were read from, saves all changed dictionaries, killing any running commands and exits the editor. The behavior is modified by flags `8` and `16`.

`0x04`

Define the exit code exitCode from MicroEmacs, the default when omitted is 0.

`0x08`

Discard changed buffers (except the history and registry) and delete any backup files associated with the edited buffer(s). This mode does not operate when bit `1` is set.

`0x10`

Discard changed buffers (except the history and registry) and create a auto save file(s) with the changes from unsaved buffers. This mode does not operate when bit `1` is set.

`0x20`

Forces the program exit status to be 1 (non-zero), which is interpreted by any parent task as an error status.

exit-emacs may be used to reproduce the behavior of save-buffers-exit-emacs(2) and quick-exit(2) as follows:

    3 exit-emacs == save-buffers-exit-emacs
    2 exit-emacs == quick-exit

## MACRO INTERACTION

If the macro shut-down(3) is defined then it is invoked by the editor when it is closed. A user defined shutdown action may be associated with the close operation. It is the callers responsibility that the macro terminates correctly otherwise the editor will hang.

## NOTES

All buffers with a name starting with a '`*`' are assumed to be system buffers (i.e. *scratch*) and are not saved.

Modes `8` and `16` may be used where the user wishes to discard edited buffers on exiting and does not want to confirm the exit. Dictionaries should be configured to auto-save in user-setup(3).

An emergency exit command which forces the editor to quit may be implemented as `0x28 exit-emacs` i.e. Force quit and exit with failed status. Internally this is what MicroEmacs uses to perform an emergency quit operation caused by signal fault etc.

## SEE ALSO

quick-exit(2), save-buffers-exit-emacs(2), shut-down(3).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>