Skip to content

Fix ghostel-debug advice arity for redraw-now's FORCE argument#463

Merged
dakra merged 1 commit into
mainfrom
fix-debug-advice-arity
Jun 24, 2026
Merged

Fix ghostel-debug advice arity for redraw-now's FORCE argument#463
dakra merged 1 commit into
mainfrom
fix-debug-advice-arity

Conversation

@dakra

@dakra dakra commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Problem

#460 gave ghostel--redraw-now an optional FORCE argument ((buffer)(buffer &optional force)). Adding an &optional arg is safe for plain callers, but advices capture arity — and the ghostel-debug advices that wrap ghostel--redraw-now still declared the old single-argument form. When debug logging or latency profiling is active, the forced redraw paths (ghostel-force-redraw, the reappear hook ghostel--window-buffer-change) signal wrong-number-of-arguments:

  • ghostel-debug--log-redraw (:around) received three args into a two-parameter lambda, and dropped FORCE when forwarding to the original.
  • ghostel-debug--latency-on-render (:after) received two args into a one-parameter lambda.

This was reported in #456 (review of #460).

Beyond the regression, ghostel-debug--log-resize (:around on ghostel--adjust-size) had the same latent bug already: ghostel--adjust-size has taken an optional FORCE for a while (a text-scale change passes it), so the resize advice would crash there too.

Notably, this also blocks diagnosing the other open parts of #456: ghostel-debug-start installs these advices, so switching workspaces (→ forced reappear redraw) throws before any useful log is produced. This fix is a precondition for debugging the rest.

Changes

  • ghostel-debug--log-redraw: accept &optional force, forward it, and fold it into the skip prediction and the force=… log column so the log stays truthful for arg-forced redraws.
  • ghostel-debug--latency-on-render: accept &rest _ (ignores the arg).
  • ghostel-debug--log-resize: accept and forward &optional force (the pre-existing latent bug).
  • test/ghostel-ime-test.el: refresh the stale declare-function arity.
  • test/ghostel-debug-test.el: regression test asserting both redraw-now advices tolerate and forward FORCE.

Only affects sessions with ghostel-debug-start / latency profiling active; normal sessions were unaffected.

make -j8 all is green.

#460 gave `ghostel--redraw-now' an optional FORCE argument, but the debug
advices that wrap it still declared the old single-argument arity.  When
debug logging or latency profiling is active, the forced redraw paths
(`ghostel-force-redraw', the reappear hook) then signal
`wrong-number-of-arguments':

- `ghostel-debug--log-redraw' (:around) received three args into a
  two-parameter lambda, and dropped FORCE when forwarding to the original.
- `ghostel-debug--latency-on-render' (:after) received two args into a
  one-parameter lambda.

Accept and forward FORCE in the :around advice (folding it into the skip
prediction and the force=... log column so the log stays truthful), and
let the :after advice ignore it via `&rest'.

`ghostel-debug--log-resize' (:around on `ghostel--adjust-size') had the
same latent bug: `ghostel--adjust-size' already took an optional FORCE
(a text-scale change passes it), so the advice would crash there too.
Fix it the same way.

Refresh the stale `declare-function' arity in ghostel-ime-test, and add a
regression test asserting both redraw-now advices tolerate and forward
FORCE.
@dakra
dakra merged commit 162cb0f into main Jun 24, 2026
24 checks passed
@dakra
dakra deleted the fix-debug-advice-arity branch June 24, 2026 10:03
@dakra
dakra temporarily deployed to github-pages June 24, 2026 10:04 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant