summaryrefslogtreecommitdiff
path: root/ledger.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-04-04 11:26:32 +0000
committerJohn Wiegley <johnw@newartisans.com>2004-04-04 11:26:32 +0000
commitf672024e06b7b03c2a9287bf75faf375955fa791 (patch)
treee06db661c2aff27be8a18490b4b076297143e196 /ledger.el
parent6f3d5be6130f9e9058a3a30470eeb0ed6c17df66 (diff)
downloadfork-ledger-f672024e06b7b03c2a9287bf75faf375955fa791.tar.gz
fork-ledger-f672024e06b7b03c2a9287bf75faf375955fa791.tar.bz2
fork-ledger-f672024e06b7b03c2a9287bf75faf375955fa791.zip
*** empty log message ***
Diffstat (limited to 'ledger.el')
-rw-r--r--ledger.el23
1 files changed, 13 insertions, 10 deletions
diff --git a/ledger.el b/ledger.el
index 5994345a..46633c95 100644
--- a/ledger.el
+++ b/ledger.el
@@ -74,21 +74,24 @@
(defun ledger-add-entry (entry)
(interactive
- (list (read-string "Entry: " (format-time-string "%m/%d "))))
- (let ((args (mapcar 'shell-quote-argument (split-string entry)))
- date entry)
- (with-temp-buffer
- (shell-command
- (concat "ledger entry "
- (mapconcat 'identity args " ")) t)
- (setq date (buffer-substring (point) (+ (point) 10)))
- (setq entry (buffer-substring (+ (point) 5) (point-max))))
+ (list (read-string "Entry: " (format-time-string "%Y/%m/%d "))))
+ (let* ((args (mapcar 'shell-quote-argument (split-string entry)))
+ (date (car args))
+ exit-code)
(if (string-match "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)" date)
(setq date (encode-time 0 0 0 (string-to-int (match-string 3 date))
(string-to-int (match-string 2 date))
(string-to-int (match-string 1 date)))))
(ledger-find-slot date)
- (insert entry)))
+ (save-excursion
+ (insert
+ (with-temp-buffer
+ (setq exit-code
+ (apply 'call-process "/home/johnw/bin/ledger" nil t nil
+ (cons "entry" args)))
+ (if (= 0 exit-code)
+ (buffer-substring (+ (point-min) 5) (point-max))
+ (concat (substring entry 5) "\n\n")))))))
(defun ledger-expand-entry ()
(interactive)