18
|
1 |
-*- mode: outline -*-
|
|
2 |
|
|
3 |
* How debug?
|
|
4 |
|
|
5 |
When your InitFile has a bug, or when you load external files that cause
|
|
6 |
errors, the bug is often hard to find, because the Emacs Lisp reader does not
|
|
7 |
know about line numbers and files – it just knows an error happened, and
|
|
8 |
that’s it.
|
|
9 |
|
|
10 |
You have several options:
|
|
11 |
|
|
12 |
* Binary Search – select half of the file in a region, and M-x eval-region.
|
|
13 |
Depending on whether that causes the error or not, split this half or the
|
|
14 |
other half again, and repeat.
|
|
15 |
|
|
16 |
* Simplified Binary Search – add (error “No error until here”) in the
|
|
17 |
middle of your file. If you get the error “No error until here” when
|
|
18 |
reloading the file, move the expression towards the back of the file,
|
|
19 |
otherwise towards the front of the file.
|
|
20 |
|
|
21 |
* Use a keyboard macro that moves forward one expression (sexp) and
|
|
22 |
evaluates it.
|
|
23 |
|
|
24 |
* Try the CommandLine? switch --debug-init.
|
|
25 |
|
|
26 |
* Shouldn’t (setq debug-on-error t) help?
|
19
|
27 |
|
|
28 |
* Using edebug.
|
|
29 |
|
|
30 |
The main entry point is ‘M-x edebug-defun’ (also on ‘C-u C-M-x’). Use it
|
|
31 |
instead of `C-x C-e’ or ‘C-M-x’ to evaluate a ‘defun’ and instrument it for
|
|
32 |
debugging.
|
|
33 |
|
|
34 |
You can disable edebug on a function by evaluating the function again using
|
|
35 |
‘C-M-x’.
|