Can anyone tell me what is going on when Emacs starts up? As I understand, Emacs has a "base," a "foundation" of code written in C, but then supposedly a great Lisp "program" takes flight. And from then on you are interacting with one big live Lisp "program," which is supposedly different than running a regular compiled C/C++ program.

But then I've never really fully understood what that really means, i.e., what the difference is between a compiled program running in live memory and a Lisp program running in, what?, a Lisp virtual world, perhaps? One specific question would be, when the elisp part of Emacs starts up, is it just like a huge tree of one initial function calling other functions that in turn call other functions? I also understand that the *scratch* and the ielm REPL allow you not only to do calculator stuff, but to actually change the running instance of Emacs, at least the running elisp code. Some explanation of this process would be illuminating.

  • 1
    Too vague/unclear. – Drew Feb 8 '20 at 17:43
  • 1
    It's a pretty wide/open question, so probably not very fit for the SX format. – Stefan Feb 8 '20 at 18:14
  • All right, simply answer (if you know) the "one specific question..." in the second paragraph. Consider the rest setup for that specific question. – 147pm Feb 8 '20 at 18:19
  • If you want to narrow your question, please do so by editing the question. Comments can be deleted at any time. Questions should stand on their own. – Drew Feb 9 '20 at 2:12

I'm not sure what a good answer could be, but you can see how the Elisp part of Emacs starts by looking at the function normal-top-level which is the Elisp function called by the C code once the C side's initialisation is done. So try:

C-h o normal-top-level RET

and then click on the link to see its source code.

  • Thanks, this is a definitie, helpful answer that can get me started. – 147pm Feb 8 '20 at 18:21

At startup Emacs runs an initialization file .emacs or .emacs.d/init.el.

When Emacs starts from a unix shell, it loads environment variables.

Emacs uses Elisp (Emacs lisp) as a command language. You don't need to know Lisp to use Emacs, except for writing the init file but you can even avoid this by using M-x customize and never look at .emacs (and the initial dot means "hidden").

You will use Lisp to automate complex Emacs tasks and ultimately to improve or adapt Emacs to your special needs (develop custom mode).

You can use Emacs to run any Lisp code.

According to Wikipedia

GNU Emacs is written in C and provides Emacs Lisp, also implemented in C, as an extension language.

But this depends on implementation and may change without you being aware of, except for performance or arithmetic limits.

GNU Emacs is built with GNU software like gcc. XEmacs is another built.

Emacs special keys derive from historical Lisp machines.

  • I'm sorry, but this doesn't really answer what I'm asking. I need to know about the elisp "virtual machine" of a running Emacs and how it differs from a compiled executable program running. Also, is this running Emacs instance a huge tree of called/evaluated/activated elisp functions and set variables? – 147pm Feb 8 '20 at 18:07
  • Generally only the lower level programs are directly executable. GNU Emacs seems to be mainly a mix of directly executable programs (compiled from C sources) and interpreted Lisp programs. As GNU Emacs source is freely available, one can check : there are compiled C executable programs and compiled Lisp executable programs, the documentation system uses info. The Elisp machine is readily available to you, for example, in the scratch window. Also, Emacs can work as server to other applications. – Pierre ALBARÈDE Feb 8 '20 at 18:47
  • Maybe some useful information in this classical paper gnu.org/software/emacs/emacs-paper.html – Pierre ALBARÈDE Feb 9 '20 at 0:29
  • Thanks, I'll take a look at it. – 147pm Feb 9 '20 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.