ledger-mode
ledger-mode copied to clipboard
New 'ledger-indent-region' function
- ledger-mode.el (ledger-mode): Set indent-region-function.
- ledger-post.el (ledger-indent-region): New function that indents the region by calling ledger-indent-line for each line.
Closes #197
@purcell hi, possible to get a quick review on this? Would be quite nice to have this fixed in master.
Probably @enderw88 would be better placed to comment on whether this is a desirable fix — I'm not sure about the history of indentation in ledger-mode
Maybe @bcc32 could take a look?
As far as I can tell, the default indent-region-function – indent-region-line-by-line – calls indent-line-function on each line. So what's the difference here, assuming that indent-line-function is set to ledger-indent-line?
ie. what you've implemented feels the same as simply not setting indent-region-function in the first place.
Good catch, I wasn't aware that indent-region worked like that by default. Just unsetting indent-region-function seems to work for me.
Test input:
2017-06-26 Commonplace Coffee
Expenses:Restaurants:Coffee 3.00 ; Grande
Assets:Cash:Wallet -3.00
2017-06-26 Commonplace Coffee
Expenses:Restaurants:Coffee 3.00 ; Grande
Assets:Cash:Wallet -3.00
2017-06-26 Commonplace Coffee
Assets:Cash:Wallet
Expenses:Restaurants:Coffee 3.00
Current master:
2017-06-26 Commonplace Coffee
Expenses:Restaurants:Coffee 3.00 ; Grande
Assets:Cash:Wallet -3.00
2017-06-26 Commonplace Coffee
Expenses:Restaurants:Coffee 3.00 ; Grande
Assets:Cash:Wallet -3.00
2017-06-26 Commonplace Coffee
Assets:Cash:Wallet
Expenses:Restaurants:Coffee 3.00
With (setq-local indent-region-function nil):
2017-06-26 Commonplace Coffee
Expenses:Restaurants:Coffee 3.00 ; Grande
Assets:Cash:Wallet -3.00
2017-06-26 Commonplace Coffee
Expenses:Restaurants:Coffee 3.00 ; Grande
Assets:Cash:Wallet -3.00
2017-06-26 Commonplace Coffee
Assets:Cash:Wallet
Expenses:Restaurants:Coffee 3.00
ledger-post-align-postings is broken somehow I guess?
ledger-post-align-postings is broken somehow I guess?
Hmmm... do we have any tests for that, perhaps? You could consider pushing a failing test to show what you'd expect.