diff options
| author | Alan Mackenzie | 2022-08-11 19:31:09 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2022-08-11 19:31:09 +0000 |
| commit | 48215c41d16fadb69e85121b3baca0dfca82cc44 (patch) | |
| tree | 1c410ce8b1b63d20cc02810078acb337af29a2b1 /src/keyboard.c | |
| parent | e7f1d4f6e106576f3d8de4074290dc4e8c7c544f (diff) | |
| download | emacs-48215c41d16fadb69e85121b3baca0dfca82cc44.tar.gz emacs-48215c41d16fadb69e85121b3baca0dfca82cc44.zip | |
New debugging facility: backtraces from errors in Lisp called from redisplay
Setting backtrace-on-redisplay-error to non-nil enables the generation of a
Lisp backtrace in buffer *Redisplay-trace* following an error in Lisp called
from redisplay.
* doc/lispref/debugging.texi (Debugging Redisplay): New subsection.
(Error Debugging): Reference to the new subsection.
* etc/NEWS: New entry for the new facility.
* src/eval.c (redisplay_deep_handler): New variable.
(init_eval): Initialize redisplay_deep_handler.
(call_debugger): Don't throw to top-level after calling debug-early
(internal_condition_case_n): "Bind" redisplay_deep_handler to the current
handler.
(backtrace_yet): New boolean variable.
(signal_or_quit): New code section to handle Lisp errors occurring in
redisplay.
(syms_of_eval): New DEFVAR_BOOL backtrace-on-redisplay-error.
* src/keyboard.c (command_loop_1): Set backtrace_yet to false each time around
the loop.
(safe_run_hooks_error): Allow args to be up to four Lisp_Objects long.
(safe_run_hooks_2): New function.
* src/lisp.h (top level): declare as externs backtrace_yet and
safe_run_hooks_2.
* src/xdisp.c (run_window_scroll_functions): Replace a call to
run_hook_with_args_2 with one to safe_run_hooks_2.
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 4ad6e4e6bd1..719226caedc 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1331,6 +1331,7 @@ command_loop_1 (void) | |||
| 1331 | display_malloc_warning (); | 1331 | display_malloc_warning (); |
| 1332 | 1332 | ||
| 1333 | Vdeactivate_mark = Qnil; | 1333 | Vdeactivate_mark = Qnil; |
| 1334 | backtrace_yet = false; | ||
| 1334 | 1335 | ||
| 1335 | /* Don't ignore mouse movements for more than a single command | 1336 | /* Don't ignore mouse movements for more than a single command |
| 1336 | loop. (This flag is set in xdisp.c whenever the tool bar is | 1337 | loop. (This flag is set in xdisp.c whenever the tool bar is |
| @@ -1841,7 +1842,7 @@ safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args) | |||
| 1841 | static Lisp_Object | 1842 | static Lisp_Object |
| 1842 | safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args) | 1843 | safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args) |
| 1843 | { | 1844 | { |
| 1844 | eassert (nargs == 2); | 1845 | eassert (nargs >= 2 && nargs <= 4); |
| 1845 | AUTO_STRING (format, "Error in %s (%S): %S"); | 1846 | AUTO_STRING (format, "Error in %s (%S): %S"); |
| 1846 | Lisp_Object hook = args[0]; | 1847 | Lisp_Object hook = args[0]; |
| 1847 | Lisp_Object fun = args[1]; | 1848 | Lisp_Object fun = args[1]; |
| @@ -1915,6 +1916,17 @@ safe_run_hooks_maybe_narrowed (Lisp_Object hook, struct window *w) | |||
| 1915 | unbind_to (count, Qnil); | 1916 | unbind_to (count, Qnil); |
| 1916 | } | 1917 | } |
| 1917 | 1918 | ||
| 1919 | void | ||
| 1920 | safe_run_hooks_2 (Lisp_Object hook, Lisp_Object arg1, Lisp_Object arg2) | ||
| 1921 | { | ||
| 1922 | specpdl_ref count = SPECPDL_INDEX (); | ||
| 1923 | |||
| 1924 | specbind (Qinhibit_quit, Qt); | ||
| 1925 | run_hook_with_args (4, ((Lisp_Object []) {hook, hook, arg1, arg2}), | ||
| 1926 | safe_run_hook_funcall); | ||
| 1927 | unbind_to (count, Qnil); | ||
| 1928 | } | ||
| 1929 | |||
| 1918 | 1930 | ||
| 1919 | /* Nonzero means polling for input is temporarily suppressed. */ | 1931 | /* Nonzero means polling for input is temporarily suppressed. */ |
| 1920 | 1932 | ||