copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.79k stars 126 forks source link

copilot-indentation-alist requires the indent value to be a symbol #252

Closed kelvie closed 8 months ago

kelvie commented 8 months ago

e.g. you can't set (add-to-list 'copilot-indentation-alist '(org-mode 2), but if you use a defvar, like here: https://github.com/chloelee767/dotfiles/blob/feba957413eab9de115c8a46301208d708a76245/doom/.doom.d/config.el#L220-L227

It'll work.

jcs090218 commented 8 months ago

Is there any error when setting the variable? What's the value of copilot-indentation-alist? 🤔 I don't think defcustom and defvar would make any differences.

kelvie commented 8 months ago
Debugger entered--Lisp error: (wrong-type-argument symbolp 2)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_35>(2)
  cl-some(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_35> (2))
  copilot--infer-indentation-offset()
  copilot--generate-doc()
  copilot--get-completion(#f(compiled-function (jsonrpc-lambda-elem1) #<bytecode 0xff2af3ebacb1718>))
  copilot-complete()
  copilot--post-command-debounce(#<buffer userscript.org>)
  apply(copilot--post-command-debounce #<buffer userscript.org>)
  timer-event-handler([t 0 0 0 nil copilot--post-command-debounce (#<buffer userscript.org>) idle 0 nil])

There is no error in the add-to-list of course

kelvie commented 8 months ago

https://github.com/copilot-emacs/copilot.el/blob/2c1c425761e3cdaf139c9e2fa531f942cfb14b16/copilot.el#L325-L328

Looks like it's here, when the alist-get returns 2, that lambda doesn't like that (never used common lisp before).

Edit: Ah it calls symbol-value on the value, so I guess it only accepts symbols (it could check if it's a number I suppose)

emil-vdw commented 8 months ago

This should be fixed by #253 (thanks to @kelvie! :trophy:). I have tested this on my side but feel free to re-open if it is not resolved.