feat(beancount): add commodity/currency completion

Was supposed to be part of d3e8ca8. Now completes commodities/currencies
from declared commidities, operating_currency options, or price
directives. Currently only works in postings, but can be later extended
to complete in price directives and operating_currency options.

Amend: d3e8ca8d9d
This commit is contained in:
Henrik Lissner
2025-05-22 21:14:34 +02:00
parent 7f8b24d1b8
commit 5df769e994

View File

@ -182,7 +182,24 @@ will theirs, recursively)."
(list (match-beginning 1) (match-end 1)
(+beancount-completion-table
(concat " \\(" (match-string-no-properties 2) "[" beancount-tag-chars "]+\\)")
1 (if (equal (match-string-no-properties 2) "#") 'tags 'links)))))))))
1 (if (equal (match-string-no-properties 2) "#") 'tags 'links))))
((progn
(goto-char pos)
(and (looking-back (concat "\\s-" beancount-number-regexp
"\\s-+\\(\\(?:" beancount-currency-regexp
"\\)?\\)")
(pos-bol))
(>= pos (match-beginning 1))
(<= pos (match-end 1))))
(list (match-beginning 1) (match-end 1)
(+beancount-completion-table
(concat "^\\(?:" beancount-date-regexp
"\\s-+commodity\\s-+\\|"
beancount-date-regexp "\\s-+price\\s-+\\|"
"option\\s-+\"operating_currency\"\\s-+\""
"\\)\\(" beancount-currency-regexp "\\)")
1 'commodities))))))))
;;;###autoload
(defun +beancount-get-account-names-a (&rest _)