Add ability to posting the account in a posting using the iedger-default-acct-transaction-indent

This commit is contained in:
Craig Earls 2013-03-02 13:33:12 -07:00
parent 497d668778
commit 9a86fe022c
3 changed files with 20 additions and 11 deletions

View file

@ -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

View file

@ -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)

View file

@ -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."