ledger-mode icon indicating copy to clipboard operation
ledger-mode copied to clipboard

ledger-report: Pass ledger-default-date-format to ledger command

Open bcc32 opened this issue 1 year ago • 4 comments

Fix #289

bcc32 avatar Mar 18 '24 21:03 bcc32

Related to #297, shouldn't we be setting this in the ledgerrc?

jdek avatar Mar 19 '24 20:03 jdek

I agree, and it does work if you just put it in .ledgerrc instead, but this custom variable already exists, and I feel we may as well make it do what it is documented to do. In addition, it is at least useful to have such a variable to override the behavior in certain contexts. However, I agree that the variable needs some thinking about. It currently doesn't distinguish between output date format and input date format, which ledger-cli does, and in fact ledger-mode reads --input-date-format from ledgerrc. It's all a bit messy, IMO.

bcc32 avatar Mar 20 '24 03:03 bcc32

https://github.com/ledger/ledger-mode/blob/130175f061c437fd7264f8b18ebb8a6b5104b638/ledger-init.el#L56-L62

I don't like implicitly using --input-date-format for the output --date-format. We need to make some clear separation here, with proper fallback to ledgerrc.

jdek avatar Mar 20 '24 04:03 jdek

I guess I was a little unclear in my previous comment---ledger-format-date is used when ledger-mode wants to insert a date into a ledger file, so defaulting to the user's preferred input format makes sense (i.e., if they specified one in ledgerrc, ledger-mode should automatically insert dates that way when editing ledger files). The only place it is used for output is in reconciliation buffers (see below) and also in ledger-schedule, which I am unfamiliar with.

--input-date-format from ledgerrc is otherwise not passed to --date-format. It is currently the case, I believe, that (with the exception of the bug this PR is designed to address), --date-format <ledger-default-date-format> is always passed to the ledger cli, which overrides ledgerrc's specification of --date-format if the latter is present.

For the reconciliation buffers, it looks like they do not actually use the ledger-reconcile-default-date-format setting at all right now. I think we should fix that bug (opened #408 to track)

bcc32 avatar Mar 20 '24 04:03 bcc32