~ubuntu-elisp/emacs/+git/master:scratch/handler-bind-2

Last commit made on 2024-01-02
Get this branch:
git clone -b scratch/handler-bind-2 https://git.launchpad.net/~ubuntu-elisp/emacs/+git/master

Branch merges

Branch information

Name:
scratch/handler-bind-2
Repository:
lp:~ubuntu-elisp/emacs/+git/master

Recent commits

4ab7a95... by =?utf-8?b?Sm/Do28gVMOhdm9yYQ==?= <email address hidden>

Use new error representaiton in ERT

* lisp/emacs-lisp/ert.el (ert--run-test-debugger): Use new error
representation.

ca7fd89... by =?utf-8?b?Sm/Do28gVMOhdm9yYQ==?= <email address hidden>

Call debug-early with new error representation

* lisp/emacs-lisp/debug-early.el (debug--early): Let debug--early
called from C know about the new representation.

2986854... by =?utf-8?b?Sm/Do28gVMOhdm9yYQ==?= <email address hidden>

Better .clangd

* .clangd (CompileFlags): Always remove -fstruct-flex-*

15305a8... by =?utf-8?b?Sm/Do28gVMOhdm9yYQ==?= <email address hidden>

Introduce handler-case (bug#68075)

* lisp/subr.el (handler-case): New macro.

* lisp/emacs-lisp/bytecomp.el (bytecomp--displaying-warnings): Use
handler-case.

* test/src/eval-tests.el (eval-tests--handler-bind): Use
handler-case, not condition-case.

* lisp/subr.el (handler-case): Don't use pcase-lambda

2009891... by =?utf-8?b?Sm/Do28gVMOhdm9yYQ==?= <email address hidden>

Experimental record type for all conditions (bug#68075)

* src/print.c (Ferror_message_string): Work with cons or with
records.
(print_error_message): Still work with cons errors, but rename
parameter.

* src/eval.c (signal_or_quit): Make a record, not a cons. Except
in the sub-case of CONDITION_CASE, where a fresh cons is given.
Name this object 'condition', not 'error'.
(skip_debugger): Rename parameter 'data' to 'condition'
(signal_quit_p)
(maybe_call_debugger): Expect record, not cons.
(syms_of_eval): Define symbol Qcondition.

26b7078... by Stefan Monnier

(backtrace-on-redisplay-error): Use `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.

b925152... by Stefan Monnier

(signal_or_quit): Preserve error object identity

Make sure we build the (ERROR-SYMBOL . ERROR-DATA) object only once
when signaling an error, so that its `eq` identity can be used.
It also gets us a tiny bit closer to having real "error objects"
like in most other current programming languages.

* src/eval.c (maybe_call_debugger): Change arglist to receive the error
object instead of receiving the signal and the data separately.
(signal_or_quit): Build the error object right at the beginning so it
stays `eq` to itself.
Rename the `keyboard_quit` arg to `continuable` so say what it does
rather than what it's used for.
(signal_quit_p): Change arg to be the error object rather than just the
error-symbol.

* src/keyboard.c (cmd_error_internal, menu_item_eval_property_1):
Adjust calls to `signal_quit_p` accordingly.

* test/src/eval-tests.el (eval-tests--error-id): New test.

c89b234... by Stefan Monnier

eval.c: Add new var `lisp-eval-depth-reserve`

Rather than blindly increase `max-lisp-eval-depth` when entering the
debugger or running `signal-hook-function`, use this new "reserve"
to keep track of how much we have grown the stack for "debugger"
purposes so that for example recursive calls to `signal-hook-function`
can't eat up the whole C stack.

* src/eval.c (max_ensure_room): Rewrite.
(restore_stack_limits): Move before `max_ensure_room`. Rewrite.
(call_debugger, signal_or_quit): Adjust calls accordingly.
Also grow `max-lisp-eval-depth` for `hander-bind` handlers.
(init_eval_once): Don't initialize `max_lisp_eval_depth` here.
(syms_of_eval): Initialize it here instead.
Add new var `lisp-eval-depth-reserve`.

* doc/lispref/eval.texi (Eval): Add `lisp-eval-depth-reserve`.

634bf61... by Stefan Monnier

(macroexp--with-extended-form-stack): Use plain `let`

`macroexp--with-extended-form-stack` used manual push/pop so that upon
non-local exits the "deeper" value is kept, so the error handler gets
to know what was the deeper value, so as to be able to compute more
precise error locations.
Replace this with a `handler-bind` which catches that "deeper" value
more explicitly.

* lisp/emacs-lisp/bytecomp.el (bytecomp--displaying-warnings):
Use `handler-bind` to catch the value of `byte-compile-form-stack`
at the time of the error. Also consolidate the duplicated code.

* lisp/emacs-lisp/macroexp.el (macroexp--with-extended-form-stack):
Use a plain dynbound let-rebinding.

6a57b91... by Stefan Monnier

Move batch backtrace code to `top_level_2`

Move ad-hoc code meant to ease debugging of bootstrap (and batch mode)
to `top_level_2` so it doesn't pollute `signal_or_quit`.

* src/lisp.h (pop_handler, push_handler_bind): Declare.
* src/keyboard.c (top_level_2): Setup an error handler to call
`debug-early` when noninteractive.
* src/eval.c (pop_handler): Not static any more.
(signal_or_quit): Remove special case for noninteractive use.
(push_handler_bind): New function, extracted from `Fhandler_bind_1`.
(Fhandler_bind_1): Use it.
(syms_of_eval): Declare `Qdebug_early__handler`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Weed out
frames below `debug-early`.
(debug-early--handler): New function.