<feed xmlns='http://www.w3.org/2005/Atom'>
<title>emacs/src, branch scratch/handler-bind</title>
<subtitle>Emacs is the extensible, customizable, self-documenting real-time display editor. 
</subtitle>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/'/>
<entry>
<title>(backtrace-on-redisplay-error): Use `handler-bind`</title>
<updated>2023-12-28T06:17:21+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2023-12-26T02:41:08+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=26b7078705ae5b9226c99e370740ab9a4063f20f'/>
<id>26b7078705ae5b9226c99e370740ab9a4063f20f</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>(signal_or_quit): Preserve error object identity</title>
<updated>2023-12-28T06:17:21+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2023-12-27T20:06:32+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=b925152bffce30abbd48361af6858cd45b785d84'/>
<id>b925152bffce30abbd48361af6858cd45b785d84</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>eval.c: Add new var `lisp-eval-depth-reserve`</title>
<updated>2023-12-28T06:16:37+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2023-12-27T04:56:09+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=c89b234405f8fa6c52f83104a46a4a2c3121198f'/>
<id>c89b234405f8fa6c52f83104a46a4a2c3121198f</id>
<content type='text'>
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`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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`.
</pre>
</div>
</content>
</entry>
<entry>
<title>Move batch backtrace code to `top_level_2`</title>
<updated>2023-12-28T05:59:54+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2023-12-21T04:31:39+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=6a57b9151b149a445daecc211d8f58010e605768'/>
<id>6a57b9151b149a445daecc211d8f58010e605768</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>New special form `handler-bind`</title>
<updated>2023-12-28T04:45:51+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2023-12-26T03:32:17+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=a4efbe4c499623b33882a770c896ebfd31459ce9'/>
<id>a4efbe4c499623b33882a770c896ebfd31459ce9</id>
<content type='text'>
AFAIK, this provides the same semantics as Common Lisp's `handler-bind`,
modulo the differences about how error objects and conditions are
represented.

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

* src/eval.c (pop_handler): New function.
(Fhandler_Bind_1): New function.
(signal_or_quit): Handle new handlertypes `HANDLER` and `SKIP_CONDITIONS`.
(find_handler_clause): Simplify.
(syms_of_eval): Defsubr `Fhandler_bind_1`.

* doc/lispref/control.texi (Handling Errors): Add `handler-bind`.

* test/src/eval-tests.el (eval-tests--handler-bind): New test.

* lisp/emacs-lisp/lisp-mode.el (lisp-font-lock-keywords):
Move 'handler-bind' from CL-only to generic Lisp.
(handler-bind): Remove indentation setting, it now lives in the macro
definition.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
AFAIK, this provides the same semantics as Common Lisp's `handler-bind`,
modulo the differences about how error objects and conditions are
represented.

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

* src/eval.c (pop_handler): New function.
(Fhandler_Bind_1): New function.
(signal_or_quit): Handle new handlertypes `HANDLER` and `SKIP_CONDITIONS`.
(find_handler_clause): Simplify.
(syms_of_eval): Defsubr `Fhandler_bind_1`.

* doc/lispref/control.texi (Handling Errors): Add `handler-bind`.

* test/src/eval-tests.el (eval-tests--handler-bind): New test.

* lisp/emacs-lisp/lisp-mode.el (lisp-font-lock-keywords):
Move 'handler-bind' from CL-only to generic Lisp.
(handler-bind): Remove indentation setting, it now lives in the macro
definition.
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert e8df6c311fcf59bf23d31b9db2bb8fec9d78fbe7</title>
<updated>2023-12-27T06:37:19+00:00</updated>
<author>
<name>Yuan Fu</name>
</author>
<published>2023-12-27T06:37:19+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=8044140b54bfe7e88c28a49cc0dc4ae129029e4f'/>
<id>8044140b54bfe7e88c28a49cc0dc4ae129029e4f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>; * src/ftfont.c (ftfont_glyph_metrics): Comment on advance rounding.</title>
<updated>2023-12-26T06:10:57+00:00</updated>
<author>
<name>Po Lu</name>
</author>
<published>2023-12-26T06:09:42+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=60199ac01d711d3240146afedd830b774eb5c5d2'/>
<id>60199ac01d711d3240146afedd830b774eb5c5d2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Consistently round glyph advances in the SFNT font backend</title>
<updated>2023-12-26T06:10:57+00:00</updated>
<author>
<name>Po Lu</name>
</author>
<published>2023-12-26T06:07:58+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=cd91ecedcbdf03ae13f45cb173360b11f13a0bc0'/>
<id>cd91ecedcbdf03ae13f45cb173360b11f13a0bc0</id>
<content type='text'>
* src/sfnt.h (SFNT_ROUND_FIXED): New macro.

* src/sfntfont.c (sfntfont_get_glyph_outline): Don't apply
advance width distortion before the glyph is instructed or
decomposed.  Round advance width as measured between both
phantom points subsequent to instruction code execution.
(sfntfont_draw): Don't take the advance's ceiling when advancing
origin point.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/sfnt.h (SFNT_ROUND_FIXED): New macro.

* src/sfntfont.c (sfntfont_get_glyph_outline): Don't apply
advance width distortion before the glyph is instructed or
decomposed.  Round advance width as measured between both
phantom points subsequent to instruction code execution.
(sfntfont_draw): Don't take the advance's ceiling when advancing
origin point.
</pre>
</div>
</content>
</entry>
<entry>
<title>Apply TTF advance width rounding to uninstructed glyphs</title>
<updated>2023-12-25T07:38:15+00:00</updated>
<author>
<name>Po Lu</name>
</author>
<published>2023-12-25T07:38:15+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=1be132731d31c3752b275735e5dbe1f60d1988c3'/>
<id>1be132731d31c3752b275735e5dbe1f60d1988c3</id>
<content type='text'>
* src/sfnt.c (sfnt_scale_metrics):

* src/sfntfont.c (sfntfont_get_glyph_outline): Round advance and
floor lbearing scaling glyph metrics.
(sfntfont_measure_pcm): Don't round or truncate metrics which
have already been.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/sfnt.c (sfnt_scale_metrics):

* src/sfntfont.c (sfntfont_get_glyph_outline): Round advance and
floor lbearing scaling glyph metrics.
(sfntfont_measure_pcm): Don't round or truncate metrics which
have already been.
</pre>
</div>
</content>
</entry>
<entry>
<title>Optimize font edge filling loop</title>
<updated>2023-12-25T03:21:15+00:00</updated>
<author>
<name>Po Lu</name>
</author>
<published>2023-12-25T03:21:15+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=995dd36da1df70c55ef2e72d4ff5b2641cc83292'/>
<id>995dd36da1df70c55ef2e72d4ff5b2641cc83292</id>
<content type='text'>
* src/sfnt.c (sfnt_fedge_sort): Delete function.
(sfnt_poly_edges_exact): Don't sort edges, iterate through each
instead.
(main): Adjust tests.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* src/sfnt.c (sfnt_fedge_sort): Delete function.
(sfnt_poly_edges_exact): Don't sort edges, iterate through each
instead.
(main): Adjust tests.
</pre>
</div>
</content>
</entry>
</feed>
