summaryrefslogtreecommitdiff
path: root/lisp/ldg-exec.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-01 16:15:51 -0700
committerCraig Earls <enderw88@gmail.com>2013-02-01 16:15:51 -0700
commit36e77bd357e41dc02b79617401845640d02963f6 (patch)
tree849c97ac942bd7ad9b16141245b6453ecd0e0a06 /lisp/ldg-exec.el
parentfdb9d0c2cae9a7827d9eaf6f7e7ba56ccc86a3fb (diff)
downloadfork-ledger-36e77bd357e41dc02b79617401845640d02963f6.tar.gz
fork-ledger-36e77bd357e41dc02b79617401845640d02963f6.tar.bz2
fork-ledger-36e77bd357e41dc02b79617401845640d02963f6.zip
Check for ledger executable and version
Altered menu creation so that menu functions are disable if there is no ledger executable available command keys will also warn if ledger isn't working remove a debug message from leg-sort
Diffstat (limited to 'lisp/ldg-exec.el')
-rw-r--r--lisp/ldg-exec.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/lisp/ldg-exec.el b/lisp/ldg-exec.el
index ab041fec..f13cfa5a 100644
--- a/lisp/ldg-exec.el
+++ b/lisp/ldg-exec.el
@@ -19,6 +19,12 @@
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
;; MA 02111-1307, USA.
+(defconst ledger-version-needed "3.0.0"
+ "The version of ledger executable needed for interactive features")
+
+(defvar ledger-works nil
+ "Flag showing whether the ledger binary can support ledger-mode interactive features")
+
(defgroup ledger-exec nil
"Interface to the Ledger command-line accounting program."
:group 'ledger)
@@ -52,4 +58,29 @@
(read (current-buffer))
(kill-buffer (current-buffer)))))
+(defun ledger-version-greater-p (needed)
+ "verify the ledger binary is usable for ledger-mode"
+ (let ((buffer ledger-buf)
+ (version-strings '())
+ (version-number))
+ (with-temp-buffer
+ (ledger-exec-ledger buffer (current-buffer) "--version")
+ (goto-char (point-min))
+ (delete-horizontal-space)
+ (setq version-strings (split-string
+ (buffer-substring-no-properties (point)
+ (+ (point) 12))))
+ (if (and (string-match (regexp-quote "Ledger") (car version-strings))
+ (or (string= needed (car (cdr version-strings)))
+ (string< needed (car (cdr version-strings)))))
+ t
+ nil))))
+
+(defun ledger-check-version ()
+ (interactive)
+ (setq ledger-works (ledger-version-greater-p ledger-version-needed))
+ (if ledger-works
+ (message "Good Ledger Version")
+ (message "Bad Ledger Version")))
+
(provide 'ldg-exec)