Partly so you won’t worry if you do it accidentally, we will now give a command to the Lisp interpreter that generates an error message. This is a harmless activity; and indeed, we will often try to generate error messages intentionally. Once you understand the jargon, error messages can be informative. Instead of being called “error” messages, they should be called “help” messages. They are like signposts to a traveler in a strange country; deciphering them can be hard, but once understood, they can point the way.
The error message is generated by a built-in GNU Emacs debugger. We
will ‘enter the debugger’. You get out of the debugger by typing
What we will do is evaluate a list that is not quoted and does not have a meaningful command as its first element. Here is a list almost exactly the same as the one we just used, but without the single-quote in front of it. Position the cursor right after it and type C-x C-e:
(this is an unquoted list)
A *Backtrace* window will open up and you should see the following in it:
---------- Buffer: *Backtrace* ---------- Debugger entered--Lisp error: (void-function this) (this is an unquoted list) eval((this is an unquoted list)) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp) ---------- Buffer: *Backtrace* ----------
Your cursor will be in this window (you may have to wait a few seconds before it becomes visible). To quit the debugger and make the debugger window go away, type:
Please type q right now, so you become confident that you can get out of the debugger. Then, type C-x C-e again to re-enter it.
Based on what we already know, we can almost read this error message.
You read the *Backtrace* buffer from the bottom up; it tells
you what Emacs did. When you typed C-x C-e, you made an
interactive call to the command
an abbreviation for ‘evaluate’ and
sexp is an abbreviation for
‘symbolic expression’. The command means ‘evaluate last symbolic
expression’, which is the expression just before your cursor.
Each line above tells you what the Lisp interpreter evaluated next. The most recent action is at the top. The buffer is called the *Backtrace* buffer because it enables you to track Emacs backwards.
At the top of the *Backtrace* buffer, you see the line:
Debugger entered--Lisp error: (void-function this)
The Lisp interpreter tried to evaluate the first atom of the list, the word ‘this’. It is this action that generated the error message ‘void-function this’.
The message contains the words ‘void-function’ and ‘this’.
The word ‘function’ was mentioned once before. It is a very important word. For our purposes, we can define it by saying that a function is a set of instructions to the computer that tell the computer to do something.
Now we can begin to understand the error message: ‘void-function this’. The function (that is, the word ‘this’) does not have a definition of any set of instructions for the computer to carry out.
The slightly odd word, ‘void-function’, is designed to cover the way Emacs Lisp is implemented, which is that when a symbol does not have a function definition attached to it, the place that should contain the instructions is ‘void’.
On the other hand, since we were able to add 2 plus 2 successfully, by
(+ 2 2), we can infer that the symbol
have a set of instructions for the computer to obey and those
instructions must be to add the numbers that follow the
It is possible to prevent Emacs entering the debugger in cases like this. We do not explain how to do that here, but we will mention what the result looks like, because you may encounter a similar situation if there is a bug in some Emacs code that you are using. In such cases, you will see only one line of error message; it will appear in the echo area and look like this:
Symbol's function definition is void: this
The message goes away as soon as you type a key, even just to move the cursor.
We know the meaning of the word ‘Symbol’. It refers to the first atom of the list, the word ‘this’. The word ‘function’ refers to the instructions that tell the computer what to do. (Technically, the symbol tells the computer where to find the instructions, but this is a complication we can ignore for the moment.)
The error message can be understood: ‘Symbol's function definition is void: this’. The symbol (that is, the word ‘this’) lacks instructions for the computer to carry out.