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

ledger-mode not formatting periodic transactions

Open ergodicbreak opened this issue 6 years ago • 2 comments

hello,

I'm new to ledger-mode and have a puzzling issue. When I input periodic transactions they're not formatted correctly. Normal transactions are OK. It ends up looking like this,

2019/12/25  automatic entry
    expenses                                     100
    assets

~ monthly  rent
expenses  1000
assets

~ Monthly  rent
expenses  1000
assets

2019/12/25  manual entry
    expenses                                     100
    assets

Moving the point over the lines of the periodic transaction highlights each line rather than the whole transactions.

My relevant init.el is

(use-package ledger-mode
  :config
  (setq ledger-binary-path "c:/users/george/bin/hledger/hledger.exe"
	ledger-mode-should-check-version nil)
  (add-to-list 'auto-mode-alist '("\.hledger\.journal" . ledger-mode))
  (add-hook 'ledger-mode-hook
          (lambda ()
            (setq-local tab-always-indent 'complete)
            (setq-local completion-cycle-threshold t)
            (setq-local ledger-complete-in-steps t)))
  )

It's probably something basic but I'm at a loss as to what. I'm on ledger-mode 4.0 and Emacs 26.2. Any ideas?

thanks, George

ergodicbreak avatar Dec 26 '19 04:12 ergodicbreak

Is that valid input anyway? Saving that to a file, flycheck-ledger displays:

 foo.ledger     5     error           Error: Unexpected date period token 'rent' (ledger)
 foo.ledger     7     error           Error: Directive 'assets' requires an argument (ledger)
 foo.ledg…     9     error           Error: Unexpected date period token 'rent' (ledger)
 foo.ledg…    11     error           Error: Directive 'assets' requires an argument (ledger)

So I think you want ~ monthly, not ~ monthly rent.

The other errors above are because the indentation was not being calculated correctly for periodic/automated transactions, and I've fixed that now in 7f680c77. :-)

purcell avatar Dec 26 '19 20:12 purcell

Thanks for the fix! You're right that input seems invalid. I was thrown off by this example in the hledger docs, https://hledger.org/journal.html#two-spaces-between-period-expression-and-description. But your fix solves it regardless.

ergodicbreak avatar Dec 27 '19 18:12 ergodicbreak