summaryrefslogtreecommitdiff
path: root/modules/ledger-config.el
blob: c268fa368239fdbc8df63c5ddac53836e7acdc8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;; ledger-config.el --- Ledger Configuration -*- lexical-binding: t; coding: utf-8; -*-
;; author Craig Jennings <c@cjennings.net>

;;; Commentary:

;; -------------------------------- Ledger Mode --------------------------------
;; edit files in ledger format

(use-package ledger-mode
  :mode ("\\.dat\\'"
         "\\.ledger\\'"
         "\\.journal\\'")
  :preface
  (defun cj/ledger-save ()
    "Automatically clean the ledger buffer at each save."
    (interactive)
    (save-excursion
      (when (buffer-modified-p)
        (with-demoted-errors (ledger-mode-clean-buffer))
        (save-buffer))))
  :bind
  (:map ledger-mode-map
        ("C-x C-s" . cj/ledger-save))
  :custom
  (ledger-clear-whole-transactions t)
  (ledger-reconcile-default-commodity "$")
  (ledger-report-use-header-line nil)
  (ledger-reports
   '(("bal"            "%(binary) --strict -f %(ledger-file) bal")
     ("bal this month" "%(binary) --strict -f %(ledger-file) bal -p %(month) -S amount")
     ("bal this year"  "%(binary) --strict -f %(ledger-file) bal -p 'this year'")
     ("net worth"      "%(binary) --strict -f %(ledger-file) bal Assets Liabilities")
     ("account"        "%(binary) --strict -f %(ledger-file) reg %(account)"))))

;; ------------------------------ Flycheck Ledger ------------------------------
;; syntax and unbalanced transaction linting

(use-package flycheck-ledger
  :after ledger-mode)

;; ------------------------------- Company Ledger ------------------------------
;; autocompletion for ledger

(use-package company-ledger
  :after (company ledger-mode)
  :config
  (add-to-list 'company-backends 'company-ledger))

(provide 'ledger-config)
;;; ledger-config.el ends here.