Skip to content

Add support for live preview of ledger xact output while adding transactions#461

Open
bcc32 wants to merge 8 commits into
ledger:masterfrom
bcc32:xact-preview
Open

Add support for live preview of ledger xact output while adding transactions#461
bcc32 wants to merge 8 commits into
ledger:masterfrom
bcc32:xact-preview

Conversation

@bcc32

@bcc32 bcc32 commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator

Add a new customization, ledger-add-transaction-idle-preview (enabled by
default) to display a preview of the ledger xact output that would be inserted
in the ledger buffer as the user is inputting a transaction text in
ledger-add-transaction. (Also affects ledger-reconcile-add).

ledger xact's exact output can be quite unpredictable, since it is hard to
remember exactly what payees exist in a ledger file, and since it depends on the
most recent transactions that match the inputted strings. Displaying a live
preview that can inform the user how to make their input more specific is a much
nicer experience than "hit enter, see that the resulting transaction is wrong,
undo, press C-c C-a again, enter date again, then press M-p to bring up previous
input".

Close #456.

@bcc32

bcc32 commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator Author

I've noticed at least one issue where the current version may sometimes swallow the user's input. I'll need to see if we're interacting with while-no-input in a bad way...

@bcc32 bcc32 marked this pull request as draft December 8, 2025 01:38
@bcc32 bcc32 marked this pull request as ready for review December 9, 2025 03:23
@bcc32

bcc32 commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator Author

I've fixed the bad interactions with while-no-input by switching to
make-process. This caused a performance hit, which I fixed by writing the
buffer contents to a temp file, which is an improvement over call-process-region
anyway.

@bcc32

bcc32 commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator Author

... and, actually delete the temp file when we're done previewing.

@bcc32 bcc32 marked this pull request as draft June 8, 2026 02:08
@bcc32

bcc32 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

Currently blocked on #474.

@bcc32 bcc32 marked this pull request as ready for review June 9, 2026 06:03
@bcc32

bcc32 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

Unfortunately, it seems necessary to decrease the test coverage requirement due to this code all being effectively untestable, at least not robustly.

On the other hand, I have been running this branch of ledger-mode myself for the last 6 months, and it works smoothly.

@bcc32 bcc32 requested a review from purcell June 10, 2026 03:58
bcc32 added 8 commits June 10, 2026 00:02
Elisp convention is that most functions may change the match data and the caller
is responsible for using save-match-data where needed.
This check should not run in temporary buffers that might be put into
ledger-mode for fontification purposes only.
This is far faster, and means the buffer contents only need to be written once.
It is still read multiple times by ledger, but hopefully from the page cache
since the file is unchanged while the user adjusts their input.
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.

ledger-add-transaction candidate narrowing

1 participant