diff options
author | Craig Earls <enderw88@gmail.com> | 2013-03-18 16:02:49 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-03-18 16:02:49 -0700 |
commit | 124058d26aa976ca3b8bc2969c16cff6881f8155 (patch) | |
tree | bcaa9d649054e99683121ae1f79a647aaf698e0f /lisp | |
parent | adfd6bafc3e276b1e7266cf03e7ab54ac70f3f90 (diff) | |
parent | 5b7186ee1fd99e547b6a9f062f155a1a8050e9c3 (diff) | |
download | fork-ledger-124058d26aa976ca3b8bc2969c16cff6881f8155.tar.gz fork-ledger-124058d26aa976ca3b8bc2969c16cff6881f8155.tar.bz2 fork-ledger-124058d26aa976ca3b8bc2969c16cff6881f8155.zip |
Merge branch 'next' into ledger-mode-automatic-transactions
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ldg-post.el | 49 | ||||
-rw-r--r-- | lisp/ldg-reconcile.el | 8 |
2 files changed, 54 insertions, 3 deletions
diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el index c871df28..d37b2f51 100644 --- a/lisp/ldg-post.el +++ b/lisp/ldg-post.el @@ -173,6 +173,55 @@ the account" (goto-char (1+ (line-end-position))) (ledger-post-align-postings))) +;; +;; This is the orignal ledger align amount code it does not attempt to format accounts +;; + + +(defun ledger-align-amounts (&optional column) + "Align amounts and accounts in the current region. +This is done so that the last digit falls in COLUMN, which +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)) + (target-col (- column offset)) + adjust) + (setq adjust (- target-col col)) + (if (< col target-col) + (insert (make-string (- target-col col) ? )) + (move-to-column target-col) + (if (looking-back " ") + (delete-char (- col target-col)) + (skip-chars-forward "^ \t") + (delete-horizontal-space) + (insert " "))) + (forward-line)))))) + +(defun ledger-post-align-amount () + "Align the amounts in this posting." + (interactive) + (save-excursion + (set-mark (line-beginning-position)) + (goto-char (1+ (line-end-position))) + (ledger-align-amounts))) + (defun ledger-post-maybe-align (beg end len) "Align amounts only if point is in a posting. BEG, END, and LEN control how far it can align." diff --git a/lisp/ldg-reconcile.el b/lisp/ldg-reconcile.el index 40795ca2..511f8f70 100644 --- a/lisp/ldg-reconcile.el +++ b/lisp/ldg-reconcile.el @@ -209,9 +209,11 @@ Return the number of uncleared xacts found." (dolist (buf (cons ledger-buf ledger-bufs)) (with-current-buffer buf (save-buffer))) - (set-buffer-modified-p nil) - (ledger-display-balance) - (goto-char curpoint))) + (with-current-buffer (get-buffer ledger-recon-buffer-name) + (set-buffer-modified-p nil) + (ledger-display-balance) + (goto-char curpoint) + (ledger-reconcile-visit t)))) (defun ledger-reconcile-finish () "Mark all pending posting or transactions as cleared. |