55 |
55 |
56 ** How debug long running command? |
56 ** How debug long running command? |
57 |
57 |
58 M-x debug-on-quit RET' and then just hit `C-g' next time it gets 'stuck' somewhere. |
58 M-x debug-on-quit RET' and then just hit `C-g' next time it gets 'stuck' somewhere. |
59 |
59 |
60 *** Check if bug in ini file. |
60 ** Check if bug in ini file not in Emacs itself. |
61 |
61 |
62 First run Emacs without loading anything: |
62 First run Emacs without loading anything: |
63 |
63 |
64 $ emacs --no-init-file --no-site-file |
64 $ emacs --no-init-file --no-site-file |
65 |
65 |
|
66 or more shortly (as '-Q' imply '-q', '--no-site-file', and '--no-splash' |
|
67 together): |
|
68 |
|
69 $ emacs -Q |
|
70 |
66 If bug not reproduced bug lies in ini files! |
71 If bug not reproduced bug lies in ini files! |
67 |
72 |
68 *** Binary Search. |
73 ** Debug by binary search. |
69 |
74 |
70 Select half of the file in a region, and M-x eval-region. Depending on whether |
75 Select half of the file in a region, and M-x eval-region. Depending on whether |
71 that causes the error or not, split this half or the other half again, and |
76 that causes the error or not, split this half or the other half again, and |
72 repeat. |
77 repeat. |
73 |
78 |
74 *** Elisp. |
79 ** Elisp debug tips. |
75 |
80 |
76 - Use a keyboard macro that moves forward one expression (sexp) and evaluates |
81 - Use a keyboard macro that moves forward one expression (sexp) and evaluates |
77 it. |
82 it. |
78 - Try C-x check-parens. |
83 - Try C-x check-parens. |
79 - Set (setq debug-on-error t). |
84 |
80 |
85 ** Enable debug mode (also on loading). |
81 *** CLI. |
86 |
82 |
87 Set in source |
83 $ emacs --no-init-file --no-site-file --debug-init |
88 |
|
89 (setq debug-on-error t) |
|
90 |
|
91 or invoke Emacs like: |
|
92 |
|
93 $ emacs --debug-init |
|
94 |
|
95 '--debug-init' which binds 'debug-on-error' to 't' while loading the init |
|
96 file, and bypasses the `condition-case' which normally catches errors in the |
|
97 init file. |
84 |
98 |
85 *** Simplified Binary Search. |
99 *** Simplified Binary Search. |
86 |
100 |
87 Add (error 'No error until here') in the middle of your file. If you get the |
101 Add (error 'No error until here') in the middle of your file. If you get the |
88 error 'No error until here' when reloading the file, move the expression |
102 error 'No error until here' when reloading the file, move the expression |