diff options
| author | Stefan Monnier | 2023-12-25 21:41:08 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2023-12-28 01:17:21 -0500 |
| commit | 26b7078705ae5b9226c99e370740ab9a4063f20f (patch) | |
| tree | 45f130466b1c6cddf5ae705a49e410979ac183a7 /src/xdisp.c | |
| parent | b925152bffce30abbd48361af6858cd45b785d84 (diff) | |
| download | emacs-scratch/handler-bind.tar.gz emacs-scratch/handler-bind.zip | |
(backtrace-on-redisplay-error): Use `handler-bind`scratch/handler-bind
Reimplement `backtrace-on-redisplay-error` using `push_handler_bind`.
This moves the code from `signal_or_quit` to `xdisp.c` and
`debug-early.el`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
Add `base` arg to strip "internal" frames.
(debug--early): New function, extracted from `debug-early`.
(debug-early, debug-early--handler): Use it.
(debug-early--muted): New function, extracted (translated) from
`signal_or_quit`; trim the buffer to a max of 10 backtraces.
* src/xdisp.c (funcall_with_backtraces): New function.
(dsafe_calln): Use it.
(syms_of_xdisp): Defsym `Qdebug_early__muted`.
* src/eval.c (redisplay_deep_handler): Delete var.
(init_eval, internal_condition_case_n): Don't set it any more.
(backtrace_yet): Delete var.
(signal_or_quit): Remove special case for `backtrace_on_redisplay_error`.
* src/keyboard.c (command_loop_1): Don't set `backtrace_yet` any more.
* src/lisp.h (backtrace_yet): Don't declare.
Diffstat (limited to 'src/xdisp.c')
| -rw-r--r-- | src/xdisp.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 2a979c5cb9e..aa1d4433914 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3072,10 +3072,24 @@ dsafe__call (bool inhibit_quit, Lisp_Object (f) (ptrdiff_t, Lisp_Object *), | |||
| 3072 | return val; | 3072 | return val; |
| 3073 | } | 3073 | } |
| 3074 | 3074 | ||
| 3075 | static Lisp_Object | ||
| 3076 | funcall_with_backtraces (ptrdiff_t nargs, Lisp_Object *args) | ||
| 3077 | { | ||
| 3078 | /* If an error is signaled during a Lisp hook in redisplay, write a | ||
| 3079 | backtrace into the buffer *Redisplay-trace*. */ | ||
| 3080 | push_handler_bind (list_of_error, Qdebug_early__muted, 0); | ||
| 3081 | Lisp_Object res = Ffuncall (nargs, args); | ||
| 3082 | pop_handler (); | ||
| 3083 | return res; | ||
| 3084 | } | ||
| 3085 | |||
| 3075 | #define SAFE_CALLMANY(inhibit_quit, f, array) \ | 3086 | #define SAFE_CALLMANY(inhibit_quit, f, array) \ |
| 3076 | dsafe__call ((inhibit_quit), f, ARRAYELTS (array), array) | 3087 | dsafe__call ((inhibit_quit), f, ARRAYELTS (array), array) |
| 3077 | #define dsafe_calln(inhibit_quit, ...) \ | 3088 | #define dsafe_calln(inhibit_quit, ...) \ |
| 3078 | SAFE_CALLMANY ((inhibit_quit), Ffuncall, ((Lisp_Object []) {__VA_ARGS__})) | 3089 | SAFE_CALLMANY ((inhibit_quit), \ |
| 3090 | backtrace_on_redisplay_error \ | ||
| 3091 | ? funcall_with_backtraces : Ffuncall, \ | ||
| 3092 | ((Lisp_Object []) {__VA_ARGS__})) | ||
| 3079 | 3093 | ||
| 3080 | static Lisp_Object | 3094 | static Lisp_Object |
| 3081 | dsafe_call1 (Lisp_Object f, Lisp_Object arg) | 3095 | dsafe_call1 (Lisp_Object f, Lisp_Object arg) |
| @@ -37748,6 +37762,8 @@ cursor shapes. */); | |||
| 37748 | DEFSYM (Qthin_space, "thin-space"); | 37762 | DEFSYM (Qthin_space, "thin-space"); |
| 37749 | DEFSYM (Qzero_width, "zero-width"); | 37763 | DEFSYM (Qzero_width, "zero-width"); |
| 37750 | 37764 | ||
| 37765 | DEFSYM (Qdebug_early__muted, "debug-early--muted"); | ||
| 37766 | |||
| 37751 | DEFVAR_LISP ("pre-redisplay-function", Vpre_redisplay_function, | 37767 | DEFVAR_LISP ("pre-redisplay-function", Vpre_redisplay_function, |
| 37752 | doc: /* Function run just before redisplay. | 37768 | doc: /* Function run just before redisplay. |
| 37753 | It is called with one argument, which is the set of windows that are to | 37769 | It is called with one argument, which is the set of windows that are to |