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

@ -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."