Files
doomemacs/modules/lang/beancount/config.el
Henrik Lissner 57b8d5fd8e fix(beancount): flymake-bean: false positives from relative paths
Beancount tools and Fava recognize relative paths in include and
document directives, and documents options. However, flymake-bean pipes
the buffer's contents to bean-check via /dev/stdin, so paths are
resolved relative to /dev instead of the location of the containing
beancount file, resulting in file errors. This commit expands those
relatives paths before sending the buffer's contents to bean-check to
resolve these false positives.
2025-05-18 00:33:14 +02:00

55 lines
2.2 KiB
EmacsLisp

;;; lang/beancount/config.el -*- lexical-binding: t; -*-
(use-package! beancount
:hook (beancount-mode . outline-minor-mode)
:hook (beancount-mode . flymake-bean-check-enable) ; FIXME: add proper flycheck support
:init
(after! nerd-icons
(add-to-list 'nerd-icons-extension-icon-alist
'("beancount" nerd-icons-faicon "nf-fa-money" :face nerd-icons-lblue))
(add-to-list 'nerd-icons-mode-icon-alist
'(beancount-mode nerd-icons-faicon "nf-fa-money" :face nerd-icons-lblue)))
:config
(set-eval-handler! 'beancount-mode #'beancount-region-default)
(setq beancount-electric-currency t)
(when (modulep! +lsp)
(add-hook 'beancount-mode-local-vars-hook #'lsp! 'append))
;; HACK: The intro message could contain ANSI color codes, causing the regexp
;; in `beancount--fava-filter' to fail to match it (and thus the browser
;; isn't automatically opened after executing `beancount-fava').
;; REVIEW: PR this upstream!
(defadvice! +beancount--open-in-browser-after-starting-fix-a (fn process output)
:around #'beancount--fava-filter
(funcall fn process (ansi-color-filter-apply output)))
;; HACK: Widens the buffer so flymake never operates on partial buffer
;; contents. Also replaces any relative file paths in include and document
;; directives with an absolute path, so bean-check doesn't throw false
;; positives due to flymake-bean's implementation.
(advice-add #'flymake-bean-check--run :override #'+beancount--flymake-bean-check--run-a)
(map! :map beancount-mode-map
:m "[[" #'+beancount/previous-transaction
:m "]]" #'+beancount/next-transaction
:localleader
"b" #'+beancount/balance
"c" #'beancount-check
"S" #'+beancount/occur
"l" #'beancount-linked
"q" #'beancount-query
"x" #'beancount-context
(:prefix ("i" . "insert")
"c" #'+beancount/clone-transaction
"C" #'+beancount/clone-this-transaction
"a" #'beancount-insert-account
"p" #'beancount-insert-prices
"d" #'beancount-insert-date)
(:prefix ("s" . "sort")
"r" #'+beancount/sort-region
"b" #'+beancount/sort-buffer)))