Built-in support for multiple passes - #140
Conversation
|
This is a good idea. Generally, I prefer minimizing a tool's surface area, which is why I originally separated the fixed-point computation from the incremental rendering. However, I agree that combining them is much more convenient and is a reasonable change to make at this stage of development. I also think it makes sense to control reruns from the editor via specific commands:
I am unsure how broken builds should be handled. Should an aux be committed only if the build succeeds? I believe so, but I'm not sure which error levels to consider (warnings are certainly fine; only failed/unterminated builds should be ignored). |
Replace the -rerun CLI flag with two editor commands: - (rerun t/nil) toggles convergence-on-idle at runtime - (rerun-once) triggers a single immediate pass When enabled, texpresso respawns the engine with the prior-pass aux after an idle window, converging TOC/refs. (rerun-once) fires in the main loop as soon as the engine's aux is ready, so it also works during active compilation cycles. Add test/test-rerun.sh + test/refs.tex to exercise parse/dispatch and end-to-end on-demand convergence via -stream. Wire the target into Makefile and CI.
05d2f2b to
6e8483e
Compare
|
Hey @let-def! Can you check out the updates? Changed I did not implement logic for failed/unterminated builds, as it most likely would require to tamper |
Hey!
Closes #35
Closes #73
Closes #77
Closes #110
This adds an opt-in
-rerunflag that makes TeXpresso converge TOC, refs, and other aux-derived state on idle, without ever running the engine twice on input the user can see. Default values are 500ms timeout on idle, 5 reruns cap, configured insrc/frontend/main.c.The idea is the following:
engine_stepuntil\end{document}is reached, then captures aux/toc/etc. intoedit_dataand respawns the engine. The new run reads prior-pass aux via the existingentry_data() edit_databranch. Repeats until aux is byte-stable (capMAX_RERUNS=5, matches latexmk default).The finishing step is cooperative —
engine_stepis interleaved withSDL_PollEventin the main loop, so the viewer stays interactive while the engine runs to end-of-doc.IMO, this is useful because when you actively writing or changing the document - the changes are instant, and no additional passes are needed, but when you want to review the document, additional refs, ToC, etc. are converged and rendered, so you can spectate your text in its whole beauty.
Let me know what you think :)
Implementation notes
txp_engine_class:aux_dirty,is_finishing,start_finishing,finish_convergence. PDF/DVI engines stub them as no-ops.bool edit_data_from_convergenceonfileentry_tso the convergence stash doesn't clobber data the editor pushed via(open ...).clear_convergence_stashis hooked intorollback_processesso a real edit invalidates the stash cleanly.setvbuf(stderr, NULL, _IONBF, 0)at the top ofmain()so[fatal]lines reach disk before a crash; previously the buffered 4KB block could swallow them.reset_seen_for_respawnwalksself->fsbefore each engine respawn and clearse->seen. Without this, the new engine's firstQ_OPRDfor a previously-read file skipsrecord_seen(0)(sincee->seen >= 0), so the trace gets no first-open entry androllback_add_changewalks pasttrace[0]into OOB memory on the next edit.