Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M-q, fill-paragraph, like ledger-mode #28

Open
bradyt opened this issue Aug 1, 2019 · 5 comments
Open

M-q, fill-paragraph, like ledger-mode #28

bradyt opened this issue Aug 1, 2019 · 5 comments

Comments

@bradyt
Copy link

bradyt commented Aug 1, 2019

In ledger-mode, if user presses M-q, it will clean up the "paragraph", that is, it will realign amounts, etc.

Would this be a good feature for hledger-mode? Users may be bringing in data added by other ledger data entry tools (like my mobile app), and may want to clean up their data once they're back at desktop. (I would put amounts all at the same column in my app, but currently, the view does not parse and present transactions in a formatted way, so I try to input the columns to a minimum for now.)

@narendraj9
Copy link
Owner

It definitely makes sense to fix it. Feel free to raise a PR. :)

@DamienCassou
Copy link
Contributor

I would appreciate a similar feature too.

@jakecoble
Copy link

IMO hledger-mode shouldn't implement this. That should be handled by Emacs' built-in alignment functions. Here's an alignment rule that will align amounts correctly. After adding it, you can select the whole buffer and run M-x align.

(add-to-list 'align-rules-list
               `(hledger-accounts
                 (regexp . ,(rx (+ space)
                             (+? anything)
                             (group-n 1 space (+ space)
                              (? ?-)
                              (+ digit)
                              (? ?.)
                              (* digit))))
                 (group . 1)
                 (spacing . 2)
                 (justify . t)
                 (separate . entire)
                 (modes . '(hledger-mode))))

@narendraj9
Copy link
Owner

Thank you @jakecoble for the helpful comment. I think it still makes sense to add the value you shared to the list of align-rules as part of hledger-mode so that it's easier to align postings by default.

@tv42
Copy link

tv42 commented Aug 1, 2022

We might as well reimplement the rest of hledger in our own init files, then.

The whole point of a package like this is to provide sane defaults. ledger-mode kept my dollar numbers aligned with just TAB. I see no reason why that would be outside the scope of hledger-mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants