(ledger-add-entry): Use Eshell to do argument parsing, since that's

the easiest way to tell if '1 "2 3" 4' contains three arguments or
four.
This commit is contained in:
John Wiegley 2005-02-17 01:21:44 +00:00
parent 2cf6fe3fc7
commit 6a5465588e

View file

@ -127,7 +127,10 @@ Return the difference in the format of a time value."
(interactive (interactive
(list (list
(read-string "Entry: " (concat ledger-year "/" ledger-month "/")))) (read-string "Entry: " (concat ledger-year "/" ledger-month "/"))))
(let* ((date (car (split-string entry-text))) (let* ((args (with-temp-buffer
(insert entry-text)
(eshell-parse-arguments (point-min) (point-max))))
(date (car args))
(insert-year t) (insert-year t)
(ledger-buf (current-buffer)) (ledger-buf (current-buffer))
exit-code) exit-code)
@ -145,13 +148,12 @@ Return the difference in the format of a time value."
(setq exit-code (setq exit-code
(apply #'ledger-run-ledger (apply #'ledger-run-ledger
ledger-buf "entry" ledger-buf "entry"
(split-string (mapcar
(with-temp-buffer (function
(insert entry-text) (lambda (x)
(goto-char (point-min)) (replace-regexp-in-string "\\([&$]\\)" "\\\\\\1"
(while (re-search-forward "\\([&$]\\)" nil t) (eval x))))
(replace-match "\\\\\\1")) args)))
(buffer-string)))))
(if (= 0 exit-code) (if (= 0 exit-code)
(if insert-year (if insert-year
(buffer-substring 2 (point-max)) (buffer-substring 2 (point-max))