From 8d3403fbef2226fc6192af8eb6b96eb715146614 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 17 Feb 2006 02:59:30 +0000 Subject: (ledger-run-ledger): Report better error messages if `ledger-binary-path' is set to an invalid value. --- ledger.el | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'ledger.el') diff --git a/ledger.el b/ledger.el index cdea2009..767e8103 100644 --- a/ledger.el +++ b/ledger.el @@ -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." -- cgit v1.2.3