ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
157 stars 54 forks source link

Enable parsing std.Progress output #70

Open erikarvstedt opened 2 years ago

erikarvstedt commented 2 years ago

This PR (based on #69) enables parsing std.Progress output in compilation and shell buffers. In particular, it unlocks proper parsing of progress output of zig build/run/... cmds.

Marked as a draft, because the implementation is a bit hacky. It requires overriding ansi-color-apply-on-region with a patched implementation (here's the patch diff). If you're interested in merging this, I'll add an implementation for Emacs 29.

You can test this with:

# Call this once to enable progress parsing
(zig-enable-progress-parsing)

# Run a `zig build-exe` demo command.
# Delete ~/.cache/zig to force compilation progress output.
(let ((compilation-environment '("TERM=ansi"))
      (shell-file-name "bash"))
  (compilation-start "rm -rf ~/.cache/zig && cd /tmp && echo 'pub fn main() void {}' > src.zig && zig build-exe src.zig"))