Reverted changes to completion. Changes were "more correct" but performance on large buffer was too poor.

This commit is contained in:
Craig Earls 2013-05-10 13:25:24 -07:00
parent 60e606a651
commit 6539f1e1a9
3 changed files with 12 additions and 32 deletions

View file

@ -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)))

View file

@ -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)

View file

@ -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)