diff options
author | Craig Earls <enderw88@gmail.com> | 2013-04-13 14:23:32 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-04-13 14:23:32 -0700 |
commit | b2c88149cb09387023b28f5af0a9ad1640a0c9c3 (patch) | |
tree | 9fee4982349fc7e0802daa03dd951b7e0a519cb2 /lisp/ldg-complete.el | |
parent | 90ced87004ed778a94326e8902c0f7c2a270f4de (diff) | |
parent | e604fe5cbb50a70d9c938c5076b2f971145328ec (diff) | |
download | fork-ledger-b2c88149cb09387023b28f5af0a9ad1640a0c9c3.tar.gz fork-ledger-b2c88149cb09387023b28f5af0a9ad1640a0c9c3.tar.bz2 fork-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-complete.el')
-rw-r--r-- | lisp/ldg-complete.el | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lisp/ldg-complete.el b/lisp/ldg-complete.el index bd907bc8..3ba35909 100644 --- a/lisp/ldg-complete.el +++ b/lisp/ldg-complete.el @@ -38,6 +38,11 @@ (point))) (end (point)) begins args) + ;; to support end of line metadata + (save-excursion + (when (search-backward ";" + (line-beginning-position) t) + (setq begin (match-beginning 0)))) (save-excursion (goto-char begin) (when (< (point) end) @@ -73,7 +78,7 @@ Return tree structure" (save-excursion (goto-char (point-min)) (while (re-search-forward - ledger-account-any-status-regex nil t) + ledger-account-or-metadata-regex nil t) (unless (and (>= origin (match-beginning 0)) (< origin (match-end 0))) (setq account-elements @@ -90,6 +95,21 @@ Return tree structure" (setq account-elements (cdr account-elements))))))) account-tree)) +(defun ledger-find-metadata-in-buffer () + "Search through buffer and build list of metadata. +Return list." + (let ((origin (point)) accounts) + (save-excursion + (setq ledger-account-tree (list t)) + (goto-char (point-min)) + (while (re-search-forward + ledger-metadata-regex + nil t) + (unless (and (>= origin (match-beginning 0)) + (< origin (match-end 0))) + (setq accounts (cons (match-string-no-properties 2) accounts))))) + accounts)) + (defun ledger-accounts () "Return a tree of all accounts in the buffer." (let* ((current (caar (ledger-parse-arguments))) @@ -157,7 +177,7 @@ Does not use ledger xact" (setq rest-of-name (match-string 3)) ;; Start copying the postings (forward-line) - (while (looking-at ledger-account-any-status-regex) + (while (looking-at ledger-account-or-metadata-regex) (setq xacts (cons (buffer-substring-no-properties (line-beginning-position) (line-end-position)) |