5. XEmacs from the Outside

XEmacs appears to the outside world as an editor, but it is really a
Lisp environment. At its heart is a Lisp interpreter; it also
"happens" to contain many specialized object types (e.g. buffers,
windows, frames, events) that are useful for implementing an editor.
Some of these objects (in particular windows and frames) have
displayable representations, and XEmacs provides a function
redisplay() that ensures that the display of all such objects
matches their internal state. Most of the time, a standard Lisp
environment is in a read-eval-print loop--i.e. "read some Lisp
code, execute it, and print the results". XEmacs has a similar loop:

read an event

dispatch the event (i.e. "do it")

redisplay

Reading an event is done using the Lisp function next-event,
which waits for something to happen (typically, the user presses a key
or moves the mouse) and returns an event object describing this.
Dispatching an event is done using the Lisp function
dispatch-event, which looks up the event in a keymap object (a
particular kind of object that associates an event with a Lisp function)
and calls that function. The function "does" what the user has
requested by changing the state of particular frame objects, buffer
objects, etc. Finally, redisplay() is called, which updates the
display to reflect those changes just made. Thus is an "editor" born.

Note that you do not have to use XEmacs as an editor; you could just
as well make it do your taxes, compute pi, play bridge, etc. You'd just
have to write functions to do those operations in Lisp.