Skip to content

More ergonomic Zig/Emacs API#260

Merged
emil-e merged 7 commits into
dakra:mainfrom
emil-e:emil-e/better-zig-emacs
May 11, 2026
Merged

More ergonomic Zig/Emacs API#260
emil-e merged 7 commits into
dakra:mainfrom
emil-e:emil-e/better-zig-emacs

Conversation

@emil-e
Copy link
Copy Markdown
Collaborator

@emil-e emil-e commented May 10, 2026

Summary

  • Replace call0/call1/... with env.f("func-name", .{args}) — a single variadic call that auto-converts Zig types to Emacs values
  • Unify signalError/logError to take format args directly; both auto-prepend ghostel: and use Emacs format syntax (%s)
  • Add convenience wrappers: env.set, env.symbolValue, env.list, env.cons
  • Reformat bindFunction docstrings to multiline string literals for readability
  • Alphabetize interned symbol list

Test plan

  • zig build passes
  • Existing terminal functionality works (redraw, input, kitty graphics)

Takes variable number of arguments and automatically converts them.
@emil-e
Copy link
Copy Markdown
Collaborator Author

emil-e commented May 11, 2026

@claude Check it out

@dakra
Copy link
Copy Markdown
Owner

dakra commented May 11, 2026

@claude review

@claude
Copy link
Copy Markdown

claude Bot commented May 11, 2026

Claude finished @dakra's task in 4m 14s —— View job


Review

Nice cleanup — the variadic env.f("name", .{args}) plus auto-converting makeValue make module.zig and Renderer.zig substantially easier to read, and folding the *f-suffixed log/error helpers into a single signature is a clear win. CLAUDE.md/AGENTS.md were updated in lockstep, which is great.

Findings (one bug, two nits) posted as inline comments:

  • BUGsrc/emacs.zig:329 env.message calls self.toFunctionArgs(objects), which doesn't exist. Only safe because the function is generic and currently unused; first caller will break the build. Easy fix: use makeValues like format does, or drop the wrapper.
  • NITsrc/emacs.zig:321 signalError (and logError) declare msg: anytype, but the body's "ghostel: " ++ msg requires comptime. Make it comptime msg: []const u8 to match intent. Also, signalError still calls self.intern("error") even though "error" was just added to the intern cache — sym.@"error" would skip the redundant lookup and stay consistent with the rest of the file.
  • NITsrc/input.zig:47 keeps an intermediate env.makeString that env.f now handles automatically; the sibling call at line 106 was already cleaned up. Pass the slice directly.

No concerns on the bindFunction multiline docstrings, the SymbolCache generator, or the [*:0]const u8 coercion from multi-line string literals. Did not run zig build (no Zig toolchain in this environment) — recommend confirming the build/tests locally per the PR's own checklist.
· emil-e/better-zig-emacs

Comment thread src/emacs.zig
Comment thread src/emacs.zig Outdated
Comment thread src/input.zig Outdated
@emil-e emil-e force-pushed the emil-e/better-zig-emacs branch from 7e9c990 to 047a600 Compare May 11, 2026 19:51
@emil-e emil-e merged commit b19e2e4 into dakra:main May 11, 2026
20 checks passed
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.

2 participants