ledger / ledger-mode

Emacs Lisp files for interacting with the C++Ledger accounting system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ledger-acounts-file not nil cause an empty completion canditates list

albreche opened this issue · comments

Hi there,
latest ledger-mode (setup with straight) and emacs-29.2 .

When ledger-accounts-file variable is set with an account files, ledger-complete-at-point returns an empty list. Under the hood as i understood, the bug come from ledger--account-list which does note return the list built from reading ledger-account-files and appending it to ledger-accounts-list-in-buffer. It lacks a call to buffer-string :

(defun ledger-accounts-list ()
  "Return a list of all known account names as strings.
Looks in `ledger-accounts-file' if set, otherwise the current buffer."
  (if ledger-accounts-file
      (let ((f ledger-accounts-file))
        (with-temp-buffer
          (insert-file-contents f)
          (ledger-accounts-list-in-buffer)
          (split-string (buffer-string) "\n") // absent in master
          ))
    (ledger-accounts-list-in-buffer)))

btw, there's no verification on the content on the file in this method.

I think you need to use account NAME declarations in the accounts file, not just a newline-separated list of account names. See the docstring of ledger-accounts-file:

The path to an optional file in which all accounts are used or declared.
This file will then be used as a source for account name completions.

"declared" means the account directive as documented here.

Yep, I just updated the docstring to mention the docstring, thanks @bcc32.

I think the feature is working as intended and no further change is required, so I'm closing the issue.