mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-22 08:04:20 +01:00
Add hledger to omen
Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
parent
52684b1723
commit
60622f12cc
45
emacs-lisp/hledger.org
Normal file
45
emacs-lisp/hledger.org
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:emacs-lisp: :comments link :results none
|
||||||
|
:ID: 2f95ff8f-b030-4c90-8296-29c1cc8b2b0c
|
||||||
|
:END:
|
||||||
|
#+title: HLedger
|
||||||
|
#+filetags: emacs-load
|
||||||
|
|
||||||
|
For hledger, it's possible to use =ledger-mode= instead of =hledger-mode=. We'll see how it goes. It does require some convincing though.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package ledger-mode
|
||||||
|
:straight t
|
||||||
|
:config
|
||||||
|
(setq ledger-binary-path "ledger-hledger")
|
||||||
|
(setq ledger-default-date-format ledger-iso-date-format)
|
||||||
|
(setq ledger-report-links-in-register nil)
|
||||||
|
(setq ledger-report-native-highlighting-arguments '("--color=always"))
|
||||||
|
(setq ledger-report-auto-width nil)
|
||||||
|
(setq ledger-reconcile-default-commodity "EUR")
|
||||||
|
(setq ledger-report-use-header-line t)
|
||||||
|
(setq ledger-report-use-native-highlighting t)
|
||||||
|
(setq ledger-report-auto-refresh-sticky-cursor t)
|
||||||
|
(setq ledger-report-use-strict t)
|
||||||
|
(setq ledger-highlight-xact-under-point t)
|
||||||
|
(setq ledger-copy-transaction-insert-blank-line-after t)
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.\\(h?ledger\\|journal\\|j\\)$" . ledger-mode))
|
||||||
|
(setq ledger-report-balance
|
||||||
|
(list "bal" (concat ledger-binary-path " --strict -f %(ledger-file) bal")))
|
||||||
|
|
||||||
|
(setq ledger-report-reg
|
||||||
|
(list "reg" (concat ledger-binary-path " --strict -f %(ledger-file) reg")))
|
||||||
|
|
||||||
|
(setq ledger-report-payee
|
||||||
|
(list "payee" (concat ledger-binary-path " --strict -f %(ledger-file) reg @%(payee)")))
|
||||||
|
|
||||||
|
(setq ledger-report-account
|
||||||
|
(list "account" (concat ledger-binary-path " --strict -f %(ledger-file) reg %(account)")))
|
||||||
|
|
||||||
|
(setq ledger-reports
|
||||||
|
(list ledger-report-balance
|
||||||
|
ledger-report-reg
|
||||||
|
ledger-report-payee
|
||||||
|
ledger-report-account)))
|
||||||
|
#+end_src
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
overlays/virtiofsd-zfs
|
overlays/virtiofsd-zfs
|
||||||
overlays/show-files-to-be-deleted
|
overlays/show-files-to-be-deleted
|
||||||
overlays/rolling_datasets
|
overlays/rolling_datasets
|
||||||
|
overlays/ledger-compat
|
||||||
|
|
||||||
inputs.uterranix.flakeModule
|
inputs.uterranix.flakeModule
|
||||||
];
|
];
|
||||||
|
|
|
@ -215,35 +215,6 @@ and work with it.
|
||||||
:hook (lsp-after-open-hook lsp-origami-try-enable))
|
:hook (lsp-after-open-hook lsp-origami-try-enable))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* hledger
|
|
||||||
|
|
||||||
For hledger, it's possible to use =ledger-mode= instead of =hledger-mode=. We'll see how it goes. It does require some convincing though.
|
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(use-package ledger-mode
|
|
||||||
:straight t
|
|
||||||
:config
|
|
||||||
(setq ledger-binary-path "hledger")
|
|
||||||
(setq ledger-mode-should-check-version nil)
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.\\(h?ledger\\|journal\\|j\\)$" . ledger-mode))
|
|
||||||
(setq ledger-report-balance
|
|
||||||
(list "bal" (concat ledger-binary-path " --strict -f %(ledger-file) bal")))
|
|
||||||
|
|
||||||
(setq ledger-report-reg
|
|
||||||
(list "reg" (concat ledger-binary-path " --strict -f %(ledger-file) reg")))
|
|
||||||
|
|
||||||
(setq ledger-report-payee
|
|
||||||
(list "payee" (concat ledger-binary-path " --strict -f %(ledger-file) reg @%(payee)")))
|
|
||||||
|
|
||||||
(setq ledger-report-account
|
|
||||||
(list "account" (concat ledger-binary-path " --strict -f %(ledger-file) reg %(account)")))
|
|
||||||
|
|
||||||
(setq ledger-reports
|
|
||||||
(list ledger-report-balance
|
|
||||||
ledger-report-reg
|
|
||||||
ledger-report-payee
|
|
||||||
ledger-report-account)))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* Projectile
|
* Projectile
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@
|
||||||
isync
|
isync
|
||||||
imagemagick
|
imagemagick
|
||||||
texlive.combined.scheme-full
|
texlive.combined.scheme-full
|
||||||
|
ledger-compat
|
||||||
|
hledger
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
emacs-master-nativecomp
|
emacs-master-nativecomp
|
||||||
rolling_datasets
|
rolling_datasets
|
||||||
virtiofsd-zfs
|
virtiofsd-zfs
|
||||||
|
ledger-compat
|
||||||
])
|
])
|
||||||
++
|
++
|
||||||
(with inputs'.nixng.overlays; [
|
(with inputs'.nixng.overlays; [
|
||||||
|
|
7
overlays/ledger-compat/default.nix
Normal file
7
overlays/ledger-compat/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{ inputs, ... }:
|
||||||
|
{
|
||||||
|
flake.overlays.ledger-compat =
|
||||||
|
final: prev: {
|
||||||
|
ledger-compat = prev.writeShellScriptBin "ledger-hledger" (builtins.readFile ./ledger.sh);
|
||||||
|
};
|
||||||
|
}
|
50
overlays/ledger-compat/ledger.sh
Normal file
50
overlays/ledger-compat/ledger.sh
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# -*- mode: shell-script -*-
|
||||||
|
|
||||||
|
iargs=("$@")
|
||||||
|
oargs=()
|
||||||
|
j=0;
|
||||||
|
date=;
|
||||||
|
for((i=0; i<${#iargs[@]}; ++i)); do
|
||||||
|
case ${iargs[i]} in
|
||||||
|
--date-format)
|
||||||
|
# drop --date-format and the next arg
|
||||||
|
i=$((i+1));
|
||||||
|
;;
|
||||||
|
--sort)
|
||||||
|
# drop --sort and the next arg
|
||||||
|
i=$((i+1));
|
||||||
|
;;
|
||||||
|
--limit)
|
||||||
|
# drop --limit and the next arg
|
||||||
|
i=$((i+1));
|
||||||
|
;;
|
||||||
|
--collapse)
|
||||||
|
# drop --collapse and the next arg
|
||||||
|
i=$((i+1));
|
||||||
|
;;
|
||||||
|
--uncleared)
|
||||||
|
oargs[j]="-UP";
|
||||||
|
j=$((j+1))
|
||||||
|
;;
|
||||||
|
xact)
|
||||||
|
# convert "xact" to "print --match"
|
||||||
|
oargs[j]=print; oargs[j+1]=--match; j=$((j+2));
|
||||||
|
# drop xact argument and stash the date argument
|
||||||
|
i=$((i+1));
|
||||||
|
date=${iargs[i]};
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# keep any other args:
|
||||||
|
oargs[j]=${iargs[i]};
|
||||||
|
j=$((j+1));
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if test "$date"
|
||||||
|
then
|
||||||
|
# substitute the given date for the old date:
|
||||||
|
hledger "${oargs[@]}" | sed "1s/....-..-../$date/"
|
||||||
|
else
|
||||||
|
hledger "${oargs[@]}"
|
||||||
|
fi
|
Loading…
Reference in a new issue