From e6a2579f349d7935657d20344115bb6903ea707d Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Sat, 19 Sep 2015 13:57:13 +0200 Subject: Add a function to "dwim" align. If no region is active, align the current transaction. If a region is active, align all postings in the region. --- lisp/ledger-post.el | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lisp') diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el index 21e856db..f648ea8f 100644 --- a/lisp/ledger-post.el +++ b/lisp/ledger-post.el @@ -146,6 +146,13 @@ at beginning of account" (setq lines-left (not (eobp))))) (setq inhibit-modification-hooks nil)))) +(defun ledger-post-align-dwim () + "Align all the posting of the current xact the current region." + (interactive) + (if (use-region-p) + (call-interactively 'ledger-post-align-postings) + (call-interactively 'ledger-post-align-xact))) + (defun ledger-post-edit-amount () "Call 'calc-mode' and push the amount in the posting to the top of stack." (interactive) -- cgit v1.2.3 From 1995a7e0ac748f6709e5051780468361bfee654d Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Sat, 19 Sep 2015 13:58:16 +0200 Subject: Bind M-q to ledger-post-align-dwim. There is very little reason to have M-q bound to fill-paragraph in ledger, so let's use it for aligning instead. --- lisp/ledger-mode.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp') diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index f2eb4b21..30f25dfc 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -285,6 +285,7 @@ With a prefix argument, remove the effective date." (define-key map [(meta ?p)] 'ledger-navigate-prev-xact-or-directive) (define-key map [(meta ?n)] 'ledger-navigate-next-xact-or-directive) + (define-key map [(meta ?q)] 'ledger-post-align-dwim) map) "Keymap for `ledger-mode'.") -- cgit v1.2.3