branch: elpa/beancount
commit e32e44e8d256578fe44da432849b3f8282526adc
Author: blais <bl...@furius.ca>
Commit: blais <bl...@furius.ca>

    Added personal binding to aggregate balance binding.
---
 etc/emacsrc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/etc/emacsrc b/etc/emacsrc
index 03c2b3cfab..7fc8bf450b 100644
--- a/etc/emacsrc
+++ b/etc/emacsrc
@@ -79,3 +79,23 @@
                     sql)))
 
 (define-key* beancount-mode-map [(control c)(j)] 
#'beancount-query-journal-at-point)
+
+
+;; TODO: Refine this a bit later on.
+(defvar beancount-balance-command
+  (concat
+   "select account, sum(position) "
+   "where account ~ '%s' "
+   "group by 1 "
+   "order by 1"))
+
+(defun beancount-query-balance-at-point ()
+  "Run a balance command for the account at point."
+  (interactive)
+  (let* ((account (thing-at-point 'beancount-account))
+         (sql (concat "\"" (format beancount-balance-command account) "\"")))
+    (beancount--run beancount-query-program
+                    (file-relative-name buffer-file-name)
+                    sql)))
+
+(define-key* beancount-mode-map [(control c)(shift j)] 
#'beancount-query-balance-at-point)

Reply via email to