Skip to content

ledger-add-xact fails in an empty buffer ignoring main ledger file #409

Open
@mikeonly

Description

@mikeonly

Hi, I am having issues running C-c C-a bound to ledger-add-transaction in a new file that has no transaction. The issue is that ledger xact executed from ledger-add-transaction returns no matches.

Relevant setup is the following:

  • main.journal with includes files and contains historical transactions
  • new.journal which I create and would like to fill with new transaction using C-c C-a functionality

I use ledger-mode in Doom Emacs through straight. I have set these variables for ledger-mode:

(setq ledger-init-file-name (expand-file-name "~/Documents/Finances/Private/main.journal")
        ledger-accounts-file (expand-file-name "~/Documents/Finances/Private/meta.journal")
        ledger-binary-path "/opt/homebrew/bin/ledger"
        ledger-default-date-format ledger-iso-date-format
        ledger-highlight-xact-under-point nil)

When I run C-c C-a with any date and uber, 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 match

2024-03-20 Uber
    Expenses:Transport:Cabs                EUR 53.36
    Assets:Visa

I 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 see ledger xact is called via call-process-region with just contents of the new.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 receive ledger-init-file-name or have ledger-master-file properly resolved? I tried setting it as a variable, but that leads to C-c C-a just failing with an error Ledger execution failed. Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions