From 5df769e994aa6906ee1a2ab0063cc92c7046b0ca Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 22 May 2025 21:14:34 +0200 Subject: [PATCH] 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: d3e8ca8d9d20 --- modules/lang/beancount/autoload/advice.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/lang/beancount/autoload/advice.el b/modules/lang/beancount/autoload/advice.el index 624d3f880..6be36edb5 100644 --- a/modules/lang/beancount/autoload/advice.el +++ b/modules/lang/beancount/autoload/advice.el @@ -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 _)