ledger / ledger-mode

Emacs Lisp files for interacting with the C++Ledger accounting system
GNU General Public License v2.0
385 stars 75 forks source link

Autocomplete does not work with Corfu #394

Closed bradprob closed 9 months ago

bradprob commented 9 months ago

Hi, auto complete does not work for me in combination with Corfu. Corfu does work in C/C++ mode. Both Corfu and ledger-mode are activated in the ledger buffer.

purcell commented 9 months ago

Please can you be more specific than "does not work?" e.g. can you provide a little snippet to show what are you typing, and where you expect a completion to be available?

purcell commented 9 months ago

FWIW, I use corfu myself and just now tried completing an account name and it worked perfectly.

bradprob commented 9 months ago

I mean that no auto-completion happens. Completion seems not to work at all. 20240114_13h17m01s_grim

Pressing C-c Tab in the screenshot results in "Foo:Foo"

bradprob commented 9 months ago

I toggled debugger on error (toggle-debug-on-error). Pressing C-c Tab, results in this message:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  ledger-fully-complete-xact()
  funcall-interactively(ledger-fully-complete-xact)
  command-execute(ledger-fully-complete-xact)

And this completion in the buffer: 20240114_13h30m51s_grim

purcell commented 9 months ago

Granted, that's not a great failure mode, but what's happening here is that you're misunderstanding the point of ledger-fully-complete-xact. It looks like the idea is that when you write "Some transaction" in the second transaction (ie. starting another transaction with the same payee) then hit C-c TAB, the prior transaction would be used to complete the first.

Probably you want is to trigger completion-at-point instead (which, in turn, would trigger corfu to use ledger's completion-at-point function). I don't think this bug report is anything to do with corfu, then — you're triggering a non-corfu function directly, so corfu isn't in the mix in your exampe.

purcell commented 9 months ago

I've never used ledger-fully-complete-xact myself btw.

For the benefit of other contributors here, this is where the error comes from, because in this case (ledger-thing-at-point) returns 'posting, so the block here is never executed.

bradprob commented 9 months ago

Thanks for the reply! Indeed I misunderstood the function of ledger-fully-complete-xact.