ledger / ledger-mode

Emacs Lisp files for interacting with the C++Ledger accounting system
GNU General Public License v2.0
377 stars 75 forks source link

New 'ledger-indent-region' function #399

Open jdek opened 6 months ago

jdek commented 6 months ago

Closes #197

jdek commented 6 months ago

@purcell hi, possible to get a quick review on this? Would be quite nice to have this fixed in master.

purcell commented 6 months ago

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

jdek commented 5 months ago

Maybe @bcc32 could take a look?

purcell commented 5 months ago

As far as I can tell, the default indent-region-functionindent-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?

purcell commented 5 months ago

ie. what you've implemented feels the same as simply not setting indent-region-function in the first place.

jdek commented 5 months ago

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?

purcell commented 5 months ago

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.