diff options
author | Craig Earls <enderw88@gmail.com> | 2014-01-07 13:25:07 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2014-01-07 13:25:07 -0700 |
commit | af84005a529b49f39927f0174b41bc31d2d04be0 (patch) | |
tree | eb4a4b5e14c7c3f8d0a31de92d46c705b5df9eb7 /lisp | |
parent | f5d5149d76af947eab90e12c61d99ed6fa7cce2f (diff) | |
download | fork-ledger-af84005a529b49f39927f0174b41bc31d2d04be0.tar.gz fork-ledger-af84005a529b49f39927f0174b41bc31d2d04be0.tar.bz2 fork-ledger-af84005a529b49f39927f0174b41bc31d2d04be0.zip |
Backed out recent changes that broke the complete cycling behavior.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ledger-complete.el | 55 | ||||
-rw-r--r-- | lisp/ledger-context.el | 47 | ||||
-rw-r--r-- | lisp/ledger-regex.el | 2 |
3 files changed, 32 insertions, 72 deletions
diff --git a/lisp/ledger-complete.el b/lisp/ledger-complete.el index 5bb69dc2..516a3a62 100644 --- a/lisp/ledger-complete.el +++ b/lisp/ledger-complete.el @@ -145,38 +145,9 @@ Return list." (cdr root)) 'string-lessp)))) -(defun ledger-command-at-point () - "Do appropriate completion for current context." - (let ((context (mapcar* - (lambda(x) (if (symbolp x) (symbol-name x))) - (ledger-context-at-point)))) - (cond - ((string= "acct-transaction" (car context)) - (concat (car context) "/" (nth 1 context))) - ((string= "pmnt-transaction" (car context)) - (concat (car context) "/" (nth 1 context))) - (t - (car context))))) - (defun ledger-complete-at-point () - "Calls the right completion function for first argument completions." - (ignore - (funcall (or (pcomplete-find-completion-function - (ledger-command-at-point)) - pcomplete-default-completion-function)))) - -(defun pcomplete/ledger-mode/empty-line () - "Complete when at empty line." - (ignore - (ledger-add-transaction (read-string "Transaction: " - (ledger-year-and-month)) (point)))) - -(defun pcomplete/ledger-mode/pmnt-transaction/date () - "Complete when at date in transaction." - (ignore)) - -(defun pcomplete/ledger-mode/pmnt-transaction/payee () - "Complete when at payee in transaction." + "Do appropriate completion for the thing at point." + (interactive) (while (pcomplete-here (if (eq (save-excursion (ledger-thing-at-point)) 'transaction) @@ -197,24 +168,8 @@ Return list." (goto-char (line-end-position)) (search-backward ";" (line-beginning-position) t) (skip-chars-backward " \t0123456789.,") - (throw 'pcompleted t))))))) - -(defun pcomplete/ledger-mode/acct-transaction/indent () - "Complete when at indent in transaction." - (ignore (ledger-thing-at-point))) - -(defun pcomplete/ledger-mode/acct-transaction/account () - "Complete when at account in transaction." - (set (make-local-variable 'pcomplete-termination-string) " ") - (pcomplete-here (ledger-accounts))) - -(defun pcomplete/ledger-mode/acct-transaction/amount () - "Complete when at amount in transaction." - (ignore (ledger-post-edit-amount))) - -(defun pcomplete/ledger-mode/acct-transaction/comment () - "Complete when at amount in transaction." - (pcomplete-here (ledger-find-metadata-in-buffer))) + (throw 'pcompleted t))) + (ledger-accounts))))) (defun ledger-fully-complete-xact () "Completes a transaction if there is another matching payee in the buffer. @@ -266,7 +221,7 @@ ledger-magic-tab would cycle properly" pcomplete-expand-and-complete pcomplete-reverse))) (progn - (delete-char pcomplete-last-completion-length) + (delete-backward-char pcomplete-last-completion-length) (if (eq this-command 'pcomplete-reverse) (progn (push (car (last pcomplete-current-completions)) diff --git a/lisp/ledger-context.el b/lisp/ledger-context.el index e9b1264b..44ad3a30 100644 --- a/lisp/ledger-context.el +++ b/lisp/ledger-context.el @@ -42,7 +42,16 @@ (defconst ledger-code-string "\\((.*)\\)?") (defconst ledger-payee-string "\\(.*\\)") -(defmacro ledger-single-line-config (&rest elements) +(defmacro ledger-line-regex (&rest elements) + (let (regex-string) + (concat (dolist (e elements regex-string) + (setq regex-string + (concat regex-string + (eval + (intern + (concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$"))) + +(defmacro ledger-single-line-config2 (&rest elements) "Take list of ELEMENTS and return regex and element list for use in context-at-point" (let (regex-string) `'(,(concat (dolist (e elements regex-string) @@ -53,25 +62,23 @@ (concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$") ,elements))) +(defmacro ledger-single-line-config (&rest elements) + "Take list of ELEMENTS and return regex and element list for use in context-at-point" + `'(,(eval `(ledger-line-regex ,@elements)) + ,elements)) + (defconst ledger-line-config - (list - (list 'pmnt-transaction - (list (ledger-single-line-config date nil status nil code nil payee nil comment) - (ledger-single-line-config date nil status nil code nil payee) - (ledger-single-line-config date nil status nil payee) - (ledger-single-line-config date nil code nil payee nil comment) - (ledger-single-line-config date nil code nil payee) - (ledger-single-line-config date nil payee) - (ledger-single-line-config date))) - (list 'acct-transaction - (list (ledger-single-line-config indent comment) - (ledger-single-line-config indent status account nil commodity amount nil comment) - (ledger-single-line-config indent status account nil commodity amount) - (ledger-single-line-config indent status account nil amount nil commodity comment) - (ledger-single-line-config indent status account nil amount nil commodity) - (ledger-single-line-config indent status account nil amount) - (ledger-single-line-config indent status account nil comment) - (ledger-single-line-config indent status account))))) + (list (list 'xact (list (ledger-single-line-config date nil status nil code nil payee nil comment) + (ledger-single-line-config date nil status nil code nil payee) + (ledger-single-line-config date nil status nil payee))) + (list 'acct-transaction (list (ledger-single-line-config indent comment) + (ledger-single-line-config2 indent status account nil commodity amount nil comment) + (ledger-single-line-config2 indent status account nil commodity amount) + (ledger-single-line-config2 indent status account nil amount nil commodity comment) + (ledger-single-line-config2 indent status account nil amount nil commodity) + (ledger-single-line-config2 indent status account nil amount) + (ledger-single-line-config2 indent status account nil comment) + (ledger-single-line-config2 indent status account))))) (defun ledger-extract-context-info (line-type pos) "Get context info for current line with LINE-TYPE. @@ -131,7 +138,7 @@ the fields in the line in a association list." ((memq first-char '(?\ ?\t)) (ledger-extract-context-info 'acct-transaction pos)) ((memq first-char '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) - (ledger-extract-context-info 'pmnt-transaction pos)) + (ledger-extract-context-info 'xact pos)) ((equal first-char ?\=) '(automated-xact nil nil)) ((equal first-char ?\~) diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el index cf10895a..06564a4a 100644 --- a/lisp/ledger-regex.el +++ b/lisp/ledger-regex.el @@ -79,8 +79,6 @@ (defconst ledger-account-cleared-regex "\\(^[ \t]+\\)\\(*\\s-*.*?\\)\\( \\|\t\\|$\\)") -(defconst ledger-metadata-regex - "[ \t]+\\(?2:;[ \t]+.+\\)$") (defmacro ledger-define-regexp (name regex docs &rest args) "Simplify the creation of a Ledger regex and helper functions." |