summaryrefslogtreecommitdiff
path: root/lisp/ldg-mode.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-04-13 14:23:32 -0700
committerCraig Earls <enderw88@gmail.com>2013-04-13 14:23:32 -0700
commitb2c88149cb09387023b28f5af0a9ad1640a0c9c3 (patch)
tree9fee4982349fc7e0802daa03dd951b7e0a519cb2 /lisp/ldg-mode.el
parent90ced87004ed778a94326e8902c0f7c2a270f4de (diff)
parente604fe5cbb50a70d9c938c5076b2f971145328ec (diff)
downloadledger-b2c88149cb09387023b28f5af0a9ad1640a0c9c3.tar.gz
ledger-b2c88149cb09387023b28f5af0a9ad1640a0c9c3.tar.bz2
ledger-b2c88149cb09387023b28f5af0a9ad1640a0c9c3.zip
Merge pull request #172 from georgek/regex
Looks good. Thanks for cleaning up the regexes. Separating the metadata form the account completion seems likely needless added complexity. What does it get us?
Diffstat (limited to 'lisp/ldg-mode.el')
-rw-r--r--lisp/ldg-mode.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el
index 4bc195ed..86889dda 100644
--- a/lisp/ldg-mode.el
+++ b/lisp/ldg-mode.el
@@ -68,13 +68,18 @@ And calculate the target-delta of the account being reconciled."
(message balance))))
(defun ledger-magic-tab (&optional interactively)
- "Decide what to with with <TAB> .
-Can be pcomplete, or align-posting"
+ "Decide what to with with <TAB>.
+Can indent, complete or align depending on context."
(interactive "p")
- (if (and (> (point) 1)
- (looking-back "[:A-Za-z0-9]" 1))
- (ledger-pcomplete interactively)
- (ledger-post-align-postings)))
+ (when (= (point) (line-end-position))
+ (if (= (point) (line-beginning-position))
+ (indent-to ledger-post-account-alignment-column)
+ (save-excursion
+ (re-search-backward ledger-account-or-metadata-regex
+ (line-beginning-position) t))
+ (when (= (point) (match-end 0))
+ (ledger-pcomplete interactively))))
+ (ledger-post-align-postings))
(defvar ledger-mode-abbrev-table)