This commit is contained in:
ry
2022-01-11 18:05:13 -08:00
parent 2046befee2
commit 8e7b654716
846 changed files with 71287 additions and 4 deletions

View File

@@ -0,0 +1,56 @@
#+TITLE: lang/ledger
#+DATE: October 13, 2019
#+SINCE: v2.0.4
#+STARTUP: inlineimages
* Table of Contents :TOC_3:noexport:
- [[#description][Description]]
- [[#module-flags][Module Flags]]
- [[#plugins][Plugins]]
- [[#hacks][Hacks]]
- [[#prerequisites][Prerequisites]]
- [[#features][Features]]
- [[#configuration][Configuration]]
* Description
This module adds support for [[https://www.ledger-cli.org/][ledger]] files. Ledger is a command line double-entry
accounting system that works with simple text files holding transactions in the
following format:
#+BEGIN_SRC ledger
2015/10/12 Exxon
Expenses:Auto:Gas $10.00
Liabilities:MasterCard $-10.00
#+END_SRC
This modules enables the following features:
+ Syntax and indentation support for ledger files
+ Add, edit, and delete transactions
+ Generate reports
+ Schedule transactions
+ Sort transactions
+ Display statistics about transactions
+ Display balance up to a point
** Module Flags
This module provides no flags.
** Plugins
+ [[https://github.com/purcell/flycheck-ledger][flycheck-ledger]]
+ [[https://github.com/atheriel/evil-ledger][evil-ledger]]
** Hacks
This module sets ~ledger-clear-whole-transactions~ to ~t~ (default value is
~nil~). This results in ~ledger-toggle-current~ toggling the clear status of the
whole transaction instead of toggling just the current posting.
* Prerequisites
In order for ~flycheck-ledger~ to work and to be able to generate reports you
will need to install [[https://www.ledger-cli.org/][ledger]].
* TODO Features
An in-depth list of features, how to use them, and their dependencies.
* Configuration
Please refer to ~ledger-mode~'s documentation for information on how to
configure it. You can do so within emacs with =C-h i=

View File

@@ -0,0 +1,88 @@
;;; lang/ledger/config.el -*- lexical-binding: t; -*-
(use-package! ledger-mode
:defer t
:init
(setq ledger-clear-whole-transactions 1
ledger-mode-should-check-version nil)
(add-hook 'ledger-mode-hook #'outline-minor-mode)
(set-company-backend! 'ledger-mode 'company-capf)
(set-popup-rules!
'(("^\\*Ledger Report" :size 0.5 :quit 'other :ttl 0)
("^\\*Ledger Error" :quit t :ttl 0)))
(defadvice! +ledger--fail-gracefully-if-absent-a (fn)
"Fail gracefully if ledger binary isn't available."
:around #'ledger-check-version
(if (executable-find ledger-binary-path)
(funcall fn)
(message "Couldn't find '%s' executable" ledger-binary-path)))
;; `ledger-mode' lacks imenu support out of the box, so we gie it some. At
;; least to make jumping to outline headings or transactions easier.
(setq-hook! 'ledger-mode-hook
imenu-generic-expression
`((nil ,(concat
"^[\\* ]+[ \t]+\\([^\n\r]+\\)\\|" ; outline headings
"^[0-9]\\{4\\}[-/.][0-9]\\{2\\}[-/.][0-9]\\{2\\}[ \t]+[^\n]+") ; transactions
0)))
(map! :map ledger-report-mode-map
"C-c C-c" #'ledger-report-edit-report
"C-c C-r" #'ledger-report-redo
"C-c C-s" #'ledger-report-save
:map ledger-reconcile-mode-map
[tab] #'ledger-reconcile-toggle))
(use-package! flycheck-ledger
:when (featurep! :checkers syntax)
:after ledger-mode)
(use-package! evil-ledger
:when (featurep! :editor evil +everywhere)
:hook (ledger-mode . evil-ledger-mode)
:config
(set-evil-initial-state! 'ledger-report-mode 'normal)
(map! (:map ledger-report-mode-map
:n "q" #'ledger-report-quit
:n "RET" #'ledger-report-edit-report
:n "gd" #'ledger-report-visit-source
:n "gr" #'ledger-report-redo
;; This is redundant, but helps `substitute-command-keys' find them
;; below, in `+ledger--fix-key-help-a'.
:n "C-d" #'evil-scroll-down
:n "C-u" #'evil-scroll-up)
(:map ledger-mode-map
:m "]]" #'ledger-navigate-next-xact-or-directive
:m "[[" #'ledger-navigate-prev-xact-or-directive)
(:localleader
:map ledger-mode-map
"a" #'ledger-add-transaction
"e" #'ledger-post-edit-amount
"t" #'ledger-toggle-current
"d" #'ledger-delete-current-transaction
"r" #'ledger-report
"R" #'ledger-reconcile
"s" #'ledger-sort-region
"S" #'ledger-schedule-upcoming
(:prefix "g"
"s" #'ledger-display-ledger-stats
"b" #'ledger-display-balance-at-point)))
(defadvice! +ledger--fix-key-help-a (fn &rest args)
"Fix inaccurate keybind message."
:around #'ledger-report
(quiet! (apply fn args))
(with-current-buffer (get-buffer ledger-report-buffer-name)
(setq header-line-format
(substitute-command-keys
(concat "\\[ledger-report-quit] to quit; "
"\\[ledger-report-redo] to redo; "
"\\[ledger-report-edit-report] to edit; "
"\\[ledger-report-save] to save; "
"\\[evil-scroll-up] and \\[evil-scroll-down] to scroll"))))))

View File

@@ -0,0 +1,4 @@
;;; lang/ledger/doctor.el -*- lexical-binding: t; -*-
(unless (executable-find "ledger")
(warn! "ledger isn't installed"))

View File

@@ -0,0 +1,10 @@
;; -*- no-byte-compile: t; -*-
;;; lang/ledger/packages.el
(package! ledger-mode :pin "19b84dc7664ea069e1a9fd446daf699574c44986")
(when (featurep! :editor evil)
(package! evil-ledger :pin "7a9f9f5d39c42fffdba8004f8982642351f2b233"))
(when (featurep! :checkers syntax)
(package! flycheck-ledger :pin "628e25ba66604946085571652a94a54f4d1ad96f"))