diff options
author | John Wiegley <johnw@newartisans.com> | 2006-02-17 02:59:30 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:24 -0400 |
commit | 8d3403fbef2226fc6192af8eb6b96eb715146614 (patch) | |
tree | 608e017b04dfd756a926ccd5e7de8c9de98557ba /ledger.el | |
parent | c1b609d4e580f7a82523dd99e3fb2e77836ea515 (diff) | |
download | fork-ledger-8d3403fbef2226fc6192af8eb6b96eb715146614.tar.gz fork-ledger-8d3403fbef2226fc6192af8eb6b96eb715146614.tar.bz2 fork-ledger-8d3403fbef2226fc6192af8eb6b96eb715146614.zip |
(ledger-run-ledger): Report better error messages if
`ledger-binary-path' is set to an invalid value.
Diffstat (limited to 'ledger.el')
-rw-r--r-- | ledger.el | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -569,23 +569,31 @@ dropped." ;; General helper functions +(defvar ledger-delete-after nil) + (defun ledger-run-ledger (buffer &rest args) "run ledger with supplied arguments" - (let ((buf (current-buffer))) - (with-current-buffer buffer - (apply #'call-process-region - (append (list (point-min) (point-max) - ledger-binary-path nil buf nil "-f" "-") - args))))) + (cond + ((null ledger-binary-path) + (error "The variable `ledger-binary-path' has not been set")) + ((not (file-exists-p ledger-binary-path)) + (error "The file `ledger-binary-path' (\"%s\") does not exist" + ledger-binary-path)) + ((not (file-executable-p ledger-binary-path)) + (error "The file `ledger-binary-path' (\"%s\") cannot be executed" + ledger-binary-path)) + (t + (let ((buf (current-buffer))) + (with-current-buffer buffer + (apply #'call-process-region + (append (list (point-min) (point-max) + ledger-binary-path ledger-delete-after + buf nil "-f" "-") + args))))))) (defun ledger-run-ledger-and-delete (buffer &rest args) - "run ledger with supplied arguments" - (let ((buf (current-buffer))) - (with-current-buffer buffer - (apply #'call-process-region - (append (list (point-min) (point-max) - ledger-binary-path t buf nil "-f" "-") - args))))) + (let ((ledger-delete-after t)) + (apply #'ledger-run-ledger buffer args))) (defun ledger-set-year (newyear) "Set ledger's idea of the current year to the prefix argument." |