refactor!(beancount): disable explicit currency

BREAKING CHANGE: If `beancount-electric-currency` is non-nil, the
currency is appended to transactions, falling back to the ledger's
"operating_currency" option, even in cases where a currency was not
explicitly needed (e.g. only one currency specified for an account).
After receiving input from beancount-mode's author, I reconsidered its
utility and decided to remove it.

Ref beancount/beancount-mode#19
This commit is contained in:
Henrik Lissner 2021-09-30 14:51:42 +02:00
parent 3ad9e39559
commit fb8d540422

View file

@ -30,22 +30,4 @@
(:prefix ("i" . "insert") (:prefix ("i" . "insert")
"a" #'beancount-insert-account "a" #'beancount-insert-account
"p" #'beancount-insert-prices "p" #'beancount-insert-prices
"d" #'beancount-insert-date)) "d" #'beancount-insert-date)))
(defadvice! +beancount--fix-account-currency-a (account)
"Fixes `beancount-electric-currency', which could never find the currency
for the current account. Also allows it to fall back to the operating_currency."
:override #'beancount--account-currency
(save-excursion
(goto-char (point-min))
(when (or (re-search-forward
(concat "^" beancount-date-regexp " +open"
"\\s-+" (regexp-quote account)
"\\s-+\\(" beancount-currency-regexp "\\)\\>")
nil t)
(re-search-forward
(concat "^option\\s-+\"operating_currency\"\\s-+\"\\("
beancount-currency-regexp
"\\)\"")
nil t))
(match-string-no-properties 1)))))