diff options
author | Craig Earls <enderw88@gmail.com> | 2013-05-10 13:25:24 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-05-10 13:25:24 -0700 |
commit | 6539f1e1a972e8ab3d3522c985ce28fa1503dc20 (patch) | |
tree | 1d8a49a5d8b341bde3f1322bc367770df000b387 /lisp | |
parent | 60e606a651f694723a69d30eb78ded5de0454b74 (diff) | |
download | fork-ledger-6539f1e1a972e8ab3d3522c985ce28fa1503dc20.tar.gz fork-ledger-6539f1e1a972e8ab3d3522c985ce28fa1503dc20.tar.bz2 fork-ledger-6539f1e1a972e8ab3d3522c985ce28fa1503dc20.zip |
Reverted changes to completion. Changes were "more correct" but performance on large buffer was too poor.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ldg-complete.el | 2 | ||||
-rw-r--r-- | lisp/ldg-mode.el | 18 | ||||
-rw-r--r-- | lisp/ldg-regex.el | 24 |
3 files changed, 12 insertions, 32 deletions
diff --git a/lisp/ldg-complete.el b/lisp/ldg-complete.el index 2faef5df..3dd48a74 100644 --- a/lisp/ldg-complete.el +++ b/lisp/ldg-complete.el @@ -82,7 +82,7 @@ (dolist (account (delete-dups (progn - (while (re-search-forward ledger-account-or-metadata-regex nil t) + (while (re-search-forward ledger-account-any-status-regex nil t) (unless (between origin (match-beginning 0) (match-end 0)) (setq accounts (cons (match-string-no-properties 2) accounts)))) accounts))) diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el index 75b842e2..f7e3d0e6 100644 --- a/lisp/ldg-mode.el +++ b/lisp/ldg-mode.el @@ -84,18 +84,12 @@ And calculate the target-delta of the account being reconciled." "Decide what to with with <TAB>. Can indent, complete or align depending on context." (interactive "p") - (when (= (point) (line-end-position)) - (if (= (point) (line-beginning-position)) - (indent-to ledger-post-account-alignment-column) - (save-excursion - (re-search-backward - (rx-static-or ledger-account-any-status-regex - ledger-metadata-regex - ledger-payee-any-status-regex) - (line-beginning-position) t)) - (when (= (point) (match-end 0)) - (ledger-pcomplete interactively)))) - (ledger-post-align-postings)) + (if (= (point) (line-beginning-position)) + (indent-to ledger-post-account-alignment-column) + (if (and (> (point) 1) + (looking-back "[:A-Za-z0-9]" 1)) + (ledger-pcomplete interactively) + (ledger-post-align-postings)))) (defvar ledger-mode-abbrev-table) diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el index cdd06d39..b15cd1de 100644 --- a/lisp/ldg-regex.el +++ b/lisp/ldg-regex.el @@ -52,10 +52,10 @@ (defconst ledger-multiline-comment-regex "^!comment\n\\(.*\n\\)*?!end_comment$") -(defconst ledger-payee-any-status-regex +(defconst ledger-payee-any-status-regex "^[0-9]+[-/][-/.=0-9]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\s-*\\(;\\|$\\)") -(defconst ledger-payee-pending-regex +(defconst ledger-payee-pending-regex "^[0-9]+[-/][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)") (defconst ledger-payee-cleared-regex @@ -68,7 +68,7 @@ "^--.+?\\($\\|[ ]\\)") (defconst ledger-account-any-status-regex - "^[ \t]+\\(?1:[*!]\\s-*\\)?\\(?2:[^ ;].*?\\)\\( \\|\t\\|$\\)") + "^[ \t]+\\([*!]\\s-+\\)?[[(]?\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)") (defconst ledger-account-pending-regex "\\(^[ \t]+\\)\\(!\\s-*.*?\\)\\( \\|\t\\|$\\)") @@ -76,20 +76,6 @@ (defconst ledger-account-cleared-regex "\\(^[ \t]+\\)\\(*\\s-*.*?\\)\\( \\|\t\\|$\\)") -(defconst ledger-metadata-regex - "[ \t]+\\(?2:;[ \t]+.+\\)$") - -(defconst ledger-account-or-metadata-regex - (concat - ledger-account-any-status-regex - "\\|" - ledger-metadata-regex)) - -(defmacro rx-static-or (&rest rx-strs) - "Returns rx union of regexps which can be symbols that eval to strings." - `(rx (or ,@(mapcar #'(lambda (rx-str) - `(regexp ,(eval rx-str))) - rx-strs)))) (defmacro ledger-define-regexp (name regex docs &rest args) "Simplify the creation of a Ledger regex and helper functions." @@ -126,7 +112,7 @@ ,(intern (concat "ledger-regex-" (symbol-name name) "-group")) string))))) - + (dolist (arg args) (let (var grouping target) (if (symbolp arg) @@ -187,7 +173,7 @@ (put 'ledger-define-regexp 'lisp-indent-function 1) (ledger-define-regexp iso-date - ( let ((sep '(or ?- ?/))) + ( let ((sep '(or ?- ?/))) (rx (group (and (group (? (= 4 num))) (eval sep) |