请问beancount如何补全多个账户文件?

我也来写一个我的配置代码。可以不通过Lsp来完成代码补全

    ;; 定义变量
    (defvar my-beancount-accounts-files nil "List of account files")

    ;; 重新定义beancount-get-account-names函数
    ;; 要注意,下面重新定义的函数,需要在加载beancount-mode代码后再加载,才能正常工作。
    (defun beancount-get-account-names ()
      "Return a list of known account names available in the predefined buffers.
    The result is cached in `beancount-accounts` to avoid repeated computation."
      (interactive)
      (unless beancount-accounts
        (let ((__accounts '()))
          (dolist (f my-beancount-accounts-files)
            ;(with-current-buffer (find-file-noselect f)
            (with-temp-buffer
              (erase-buffer)
              (insert-file-contents f)
              (goto-char (point-min))
              ;; 使用 add-to-list 向列表中添加唯一元素。
              (add-to-list '__accounts (sort (beancount-collect-unique beancount-account-regexp 0) #'string< ) )))
          ;; Flatten the nested lists and cache the result
          (setq beancount-accounts (flatten-tree (reverse __accounts)))))
      beancount-accounts)

    ;; 设置account变量。
    ;; (setq my-beancount-accounts-files '("~/investing-book/accounts/Assets.bean"
    ;;                                     "~/investing-book/accounts/Expenses.bean"
    ;;                                     "~/investing-book/accounts/Income.bean"
    ;;                                     "~/investing-book/accounts/Liabilities.bean"
    ;;                                     "~/investing-book/accounts/Securities.bean"
    ;;                                     "~/investing-book/accounts/Commodities.bean"
    ;;                                     ))
    ;; 改进代码:从指定目录中更好的自动发现Account name 
    (setq bean-project-root "~/investing-book")
    (setq my-beancount-accounts-files
          (directory-files (concat bean-project-root "/accounts") t "\.bean$"))
    (setq beancount-use-ido nil) ;;使用其他框架完成补全工作
1 个赞