Open mikeonly opened 7 months ago
ledger-init-file-name
is supposed to be the path to your ledger configuration, e.g., ~/.ledgerrc
, not a journal file.
ledger-master-file
is (in addition to being a function) a buffer-local variable that is designed to be set file-locally. E.g., use M-x add-file-local-variable
to set ledger-master-file
to main.journal
in new.journal
.
See the docstring of ledger-master-file
:
Return the master file for a ledger file.
The master file is either the file for the current ledger buffer or the file specified by the buffer-local variable ledger-master-file. Typically this variable would be set in a file local variable comment block at the end of a ledger file which is included in some other file.
Thanks for clarifying the confusion, indeed. However, even when I set these values to proper values, I still get error Ledger execution failed
.
Here's what I add to new.journal
:
; Local Variables:
; ledger-master-file: "/Users/mf/Documents/Finances/Private/main.journal"
; End:
and I see that the variable ledger-master-file
is set properly locally. I then adjust ledger-init-file-name
and point it to ~/.ledgerrc
which contains just --sort date
line.
If you could suggest how I can pin point exactly what fails and give more debugging info, I'd really appreciate that!
Ah, I see. Looking at it now, it looks like ledger-master-file
is simply not used for ledger-add-transaction
(it is used for reports and flymake). I don't know if this is necessarily on purpose, but it seems that ledger-add-transaction always uses the current buffer. It seems useful to have it use the master file (if such a variable is set), but one nice thing about having it use the current buffer's contents is that you can add the same transaction twice in a row really easily without having to save the file in between, so it's not 100% clear if changing the behavior is the right move. @purcell, do you have thoughts on this issue?
Not sure there's an objectively best choice, sorry. You wouldn't necessarily want to force the current file to be saved, nor should you necessarily need all the other files included by ledger-master-file
to be well-formed. I feel like the master file is more about operations where it's important that everything is balanced/reconciled appropriately. I guess I'd probably lean towards preserving the current behaviour, then, but I don't feel strongly about it.
Hi, I am having issues running
C-c C-a
bound toledger-add-transaction
in a new file that has no transaction. The issue is thatledger xact
executed fromledger-add-transaction
returns no matches.Relevant setup is the following:
main.journal
with includes files and contains historical transactionsnew.journal
which I create and would like to fill with new transaction usingC-c C-a
functionalityI use
ledger-mode
in Doom Emacs through straight. I have set these variables forledger-mode
:When I run
C-c C-a
with any date anduber
, ledger-mode raises error:Error: No accounts, and no past transaction matching 'uber'
However, in cli,
ledger xact 2023-11-11 uber
would give a matchI suspect the error occurs here in ledger-exec-ledger code. In fact,
(ledger-master-file)
resolves to the current buffer,new.journal
, which is empty, and so as far as I seeledger xact
is called viacall-process-region
with just contents of thenew.journal
file, i.e. with no historical transactions.Am I missing anything to make
C-c C-a
work in the config, that is, to receiveledger-init-file-name
or haveledger-master-file
properly resolved? I tried setting it as a variable, but that leads toC-c C-a
just failing with an errorLedger execution failed
. Thanks :)