diff options
-rw-r--r-- | doc/ledger-mode.texi | 5 | ||||
-rw-r--r-- | lisp/ldg-mode.el | 5 | ||||
-rw-r--r-- | lisp/ldg-post.el | 21 |
3 files changed, 20 insertions, 11 deletions
diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 336f5ba8..1d317725 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -596,8 +596,6 @@ for Ledger under the data options. Alternately you can choose @node Ledger Customization Group, Ledger Reconcile Customization Group, Customization Variables, Customization Variables @subsection Ledger Customization Group @table @code -@item ledger-default-acct-transaction-indent - Default indentation for account transactions in an entry. @item ledger-occur-use-face-unfolded If non-nil use a custom face for xacts shown in `ledger-occur' mode using @code{ledger-occur-xact-face}. @item ledger-clear-whole-transactions @@ -678,11 +676,14 @@ Default face for pending (!) transactions in the reconcile window @subsection Ledger Post Customization Group Ledger Post : @table @code + @item ledger-post-auto-adjust-amounts If non-nil, then automatically align amounts to column specified in @code{ledger-post-amount-alignment-column} @item ledger-post-amount-alignment-column The column Ledger-mode uses to align amounts +@item ledger-default-acct-transaction-indent +Default indentation for account transactions in an entry. @item ledger-post-use-completion-engine Which completion engine to use, iswitchb, ido, or built-in @item ledger-post-use-ido diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el index 37c0f69e..00df0e67 100644 --- a/lisp/ldg-mode.el +++ b/lisp/ldg-mode.el @@ -39,11 +39,6 @@ (defvar ledger-month (ledger-current-month) "Start a ledger session with the current month, but make it customizable to ease retro-entry.") -(defcustom ledger-default-acct-transaction-indent " " - "Default indentation for account transactions in an entry." - :type 'string - :group 'ledger) - (defun ledger-remove-overlays () "Remove all overlays from the ledger buffer." (interactive) diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el index de28a8a9..2a736bfc 100644 --- a/lisp/ldg-post.el +++ b/lisp/ldg-post.el @@ -27,6 +27,11 @@ ;;; Code: +(defcustom ledger-default-acct-transaction-indent " " + "Default indentation for account transactions in an entry." + :type 'string + :group 'ledger-post) + (defgroup ledger-post nil "Options for controlling how Ledger-mode deals with postings and completion" :group 'ledger) @@ -119,17 +124,25 @@ PROMPT is a string to prompt with. CHOICES is a list of (match-end 3)) (point)))) (defun ledger-align-amounts (&optional column) - "Align amounts in the current region. + "Align amounts and accounts in the current region. This is done so that the last digit falls in COLUMN, which - defaults to 52." +defaults to 52. ledger-default-acct-transaction-indent positions +the account" (interactive "p") (if (or (null column) (= column 1)) (setq column ledger-post-amount-alignment-column)) (save-excursion + ;; Position the account + (beginning-of-line) + (set-mark (point)) + (delete-horizontal-space) + (insert ledger-default-acct-transaction-indent) + (goto-char (1+ (line-end-position))) (let* ((mark-first (< (mark) (point))) (begin (if mark-first (mark) (point))) (end (if mark-first (point-marker) (mark-marker))) offset) + ;; Position the amount (goto-char begin) (while (setq offset (ledger-next-amount end)) (let ((col (current-column)) @@ -159,10 +172,10 @@ This is done so that the last digit falls in COLUMN, which BEG, END, and LEN control how far it can align." (save-excursion (goto-char beg) - (when (< end (line-end-position)) + (when (<= end (line-end-position)) (goto-char (line-beginning-position)) (if (looking-at ledger-post-line-regexp) - (ledger-post-align-amount))))) + (ledger-align-amounts))))) (defun ledger-post-edit-amount () "Call 'calc-mode' and push the amount in the posting to the top of stack." |