rejeep / prodigy.el

Manage external services from within Emacs
GNU General Public License v3.0
550 stars 39 forks source link

wip: Apply backspace to log output #112

Closed Fuco1 closed 2 years ago

Fuco1 commented 6 years ago

Tools like webpack print a lot of ^H into the output to simulate the "update-in-place" effect in the terminal. This litters the prodigy buffer with thousands of lines of crap.

I've added a bit of code to "interpret" the ^H as a "delete one char back". The implementation I don't quite like because:

  1. It is not an output filter. However with the current design it's impossible to design it as such because the backspaces might come chunked and so we can't only "filter on one chunk at a time" (the variable output in prodigy-process-output).
  2. It is an ad-hoc implementation for one control-sequence.

Maybe we can introduce a new hook variable that would work directly on the log buffer instead of only on the chunks and start placing these functions there.

I've tried to make use of term which would be super cool but it is quite rigid in how its implemented and seems that hacking it to somehow be usable as a generic filter is quite impossible, so we might need to implement bits and pieces ourselves.

I'm opening this up for discussion/design decisions.

rejeep commented 6 years ago

This does not solve all possible cases, but is it possible to run webpack with another output format?

Fuco1 commented 6 years ago

I imagine it's not only webpack which does this though. Ideally I would like it to interpret all the control sequences (a la ansi-term but that seems incredibly difficult to make reliable outside of actually running a term

rejeep commented 6 years ago

It would definitely be optimal yes. The part of ansi-term that does this could probably be a mode in itself so it could be used elsewhere, here for example.

Fuco1 commented 6 years ago

Note to self: we can try to repurpose or copy/change the function term-handle-ansi-escape which seems to handle the ansi movements. I think reuse is virtually impossible because of how the term mode operates (there is no scrollback, inplace mod etc.)

DamienCassou commented 2 years ago

I'm closing all old PRs. If you still care, please rebase your branch and reopen the PR.