diff options
author | Steve Purcell <steve@sanityinc.com> | 2019-06-15 15:03:14 +1200 |
---|---|---|
committer | Steve Purcell <steve@sanityinc.com> | 2019-06-15 15:03:14 +1200 |
commit | c5cc2f7b26237e828b1083751e3f4a38d332549a (patch) | |
tree | c44def6b2b7c37891639620c806294ef797e0c9e | |
parent | 03c3d01379d3c88834ecabdd3d818cfc7f0ca38f (diff) |
Allow automatic realignment of posting amounts to be disabled
Fixes #176
-rw-r--r-- | doc/ledger-mode.texi | 3 | ||||
-rw-r--r-- | ledger-complete.el | 2 | ||||
-rw-r--r-- | ledger-post.el | 9 |
3 files changed, 12 insertions, 2 deletions
diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index ae7b0c6..555b005 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -295,6 +295,9 @@ last digit is aligned to the column specified by @option{ledger-post-amount-alignment-column}, which defaults to @samp{52}. @xref{Ledger Post Customization Group}. +To prevent the automatic realignment of amounts, disable +@option{ledger-post-auto-align}. @xref{Ledger Post Customization Group}. + @menu * Setting a Transactions Effective Date:: * Quick Balance Display:: diff --git a/ledger-complete.el b/ledger-complete.el index 09d41c1..e030fbe 100644 --- a/ledger-complete.el +++ b/ledger-complete.el @@ -266,7 +266,7 @@ Looks in `ledger-accounts-file' if set, otherwise the current buffer." :exit-function (lambda (&rest _) (when delete-suffix (delete-char delete-suffix)) - (when realign-after + (when (and realign-after ledger-post-auto-align) (ledger-post-align-postings (line-beginning-position) (line-end-position)))) 'ignore)))) diff --git a/ledger-post.el b/ledger-post.el index b3ec9b1..982863d 100644 --- a/ledger-post.el +++ b/ledger-post.el @@ -52,6 +52,12 @@ decimal separator." (const :tag "align at the decimal separator" :decimal)) :group 'ledger-post) +(defcustom ledger-post-auto-align t + "When non-nil, realign post amounts when indenting or completing." + :type 'boolean + :group 'ledger-post + :safe 'booleanp) + (defun ledger-next-amount (&optional end) "Move point to the next amount, as long as it is not past END. Return the width of the amount field as an integer and leave @@ -131,7 +137,8 @@ Looks only as far as END, if supplied, otherwise `point-max'." (back-to-indentation) (delete-horizontal-space t) (indent-to indent-level))) - (ledger-post-align-postings (line-beginning-position) (line-end-position))) + (when ledger-post-auto-align + (ledger-post-align-postings (line-beginning-position) (line-end-position)))) (defun ledger-post-align-dwim () "Align all the posting of the current xact or the current region. |