Account auto formatting now works with tab completion

This commit is contained in:
Craig Earls 2013-03-06 21:13:06 -05:00
parent 81eeb210e8
commit 27d27ecb6c
4 changed files with 16 additions and 13 deletions

View file

@ -145,16 +145,17 @@ Return tree structure"
"Completes a transaction if there is another matching payee in the buffer. "Completes a transaction if there is another matching payee in the buffer.
Does not use ledger xact" Does not use ledger xact"
(interactive) (interactive)
(let ((name (caar (ledger-parse-arguments))) (let* ((name (caar (ledger-parse-arguments)))
rest-of-name (rest-of-name name)
xacts) xacts)
(save-excursion (save-excursion
(when (eq 'transaction (ledger-thing-at-point)) (when (eq 'transaction (ledger-thing-at-point))
(delete-region (point) (+ (length name) (point)))
;; Search backward for a matching payee ;; Search backward for a matching payee
(when (re-search-backward (when (re-search-backward
(concat "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+" (concat "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.*"
(regexp-quote name) ) nil t) ;; "\\(\t\\|\n\\| [ \t]\\)" (regexp-quote name) ".*\\)" ) nil t) ;; "\\(\t\\|\n\\| [ \t]\\)"
(setq rest-of-name (buffer-substring-no-properties (match-end 0) (line-end-position))) (setq rest-of-name (match-string 3))
;; Start copying the postings ;; Start copying the postings
(forward-line) (forward-line)
(while (looking-at "^\\s-+") (while (looking-at "^\\s-+")

View file

@ -133,10 +133,15 @@ the account"
(setq column ledger-post-amount-alignment-column)) (setq column ledger-post-amount-alignment-column))
(save-excursion (save-excursion
;; Position the account ;; Position the account
;; (beginning-of-line) (if (not
(set-mark (point)) (and (looking-at "[ \t]+\n")
;; (delete-horizontal-space) (looking-back "[ \n]" (- (point) 2))))
;; (insert ledger-default-acct-transaction-indent) (progn
(beginning-of-line)
(set-mark (point))
(delete-horizontal-space)
(insert ledger-default-acct-transaction-indent))
(set-mark (point)))
(goto-char (1+ (line-end-position))) (goto-char (1+ (line-end-position)))
(let* ((mark-first (< (mark) (point))) (let* ((mark-first (< (mark) (point)))
(begin (if mark-first (mark) (point))) (begin (if mark-first (mark) (point)))

View file

@ -397,7 +397,7 @@ POSTING is used in `ledger-clear-whole-transactions' is nil."
(defvar ledger-reconcile-mode-abbrev-table) (defvar ledger-reconcile-mode-abbrev-table)
(defun ledger-reconcile-change-target () (defun ledger-reconcile-change-target ()
"Change the traget amount for the reconciliation process." "Change the target amount for the reconciliation process."
(interactive) (interactive)
(setq ledger-target (ledger-read-commodity-string "Set reconciliation target"))) (setq ledger-target (ledger-read-commodity-string "Set reconciliation target")))

View file

@ -118,9 +118,6 @@ within the transaction."
(replace-match date) (replace-match date)
(re-search-forward "[1-9][0-9]+\.[0-9]+"))) (re-search-forward "[1-9][0-9]+\.[0-9]+")))
(provide 'ldg-xact)
(provide 'ldg-xact) (provide 'ldg-xact)
;;; ldg-xact.el ends here ;;; ldg-xact.el ends here