copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.8k stars 127 forks source link

(wrong-type-argument sequencep editorconfig--get-indentation-lisp-mode) #323

Closed ultronozm closed 3 months ago

ultronozm commented 3 months ago

This error occurs when using copilot with a sufficiently recent Emacs master, containing editorconfig 0.11.0. Typing any character in an elisp file with copilot enabled yields a backtrace like the following:

Debugger entered--Lisp error: (wrong-type-argument sequencep editorconfig--get-indentation-lisp-mode) cl-mapcar(#f(compiled-function (&rest cl-x) #<bytecode -0xd3a7a5cd65707f6>) editorconfig--get-indentation-lisp-mode) cl-map(nil #f(compiled-function (&rest cl-x) #<bytecode -0xd3a7a5cd65707f6>) editorconfig--get-indentation-lisp-mode) apply(cl-map nil #f(compiled-function (&rest cl-x) #<bytecode -0xd3a7a5cd65707f6>) editorconfig--get-indentation-lisp-mode nil) cl-some(#f(lambda (s) [t] (cond ((numberp s) s) ((and (boundp s) (numberp (symbol-value s))) (symbol-value s)))) editorconfig--get-indentation-lisp-mode) (progn (cl-some #'(lambda (s) (cond ((numberp s) s) ((and (boundp s) (numberp ...)) (symbol-value s)))) (alist-get mode copilot-indentation-alist))) (if mode (progn (cl-some #'(lambda (s) (cond ((numberp s) s) ((and ... ...) (symbol-value s)))) (alist-get mode copilot-indentation-alist)))) (let ((mode major-mode)) (while (and (not (assq mode copilot-indentation-alist)) (setq mode (get mode 'derived-mode-parent)))) (if mode (progn (cl-some #'(lambda (s) (cond (... s) (... ...))) (alist-get mode copilot-indentation-alist))))) (or (let ((mode major-mode)) (while (and (not (assq mode copilot-indentation-alist)) (setq mode (get mode 'derived-mode-parent)))) (if mode (progn (cl-some #'(lambda (s) (cond ... ...)) (alist-get mode copilot-indentation-alist))))) (progn (if (and (not copilot-indent-offset-warning-disable) (not copilot--indent-warning-printed-p)) (progn (display-warning '(copilot copilot-no-mode-indent) "copilot--infer-indentation-offset found no mode-specific indentation offset.") (set (make-local-variable 'copilot--indent-warning-printed-p) t))) tab-width)) copilot--infer-indentation-offset() copilot--generate-doc() copilot--get-completion(#f(compiled-function (jsonrpc-lambda-elem1) #<bytecode 0x181f495dcbfa795>)) copilot-complete() copilot--post-command-debounce(#) apply(copilot--post-command-debounce #) timer-event-handler([t 0 0 0 nil copilot--post-command-debounce (#) idle 0 nil])

My fork contains a fix (https://github.com/copilot-emacs/copilot.el/commit/c3e1101defaa3d75d45d1344037796e8136f9dcf), which I'll submit as a PR once my earlier PR https://github.com/copilot-emacs/copilot.el/pull/309 is accepted.

zerolfx commented 3 months ago

@ultronozm Do you want to fix two bugs in a single PR or use separate ones? I'm going to merge your earlier PR.

Sorry for the delay in merging. And as always, thanks for your contributions.

ultronozm commented 3 months ago

OK, it looks like I don't really know how to use github, and I inadvertently added my fix for this issue to the same PR, as you've pointed out. I'm happy to fix two bugs in the same PR. If you'd prefer to see them disentangled, that's fine with me, too. Thanks!

ultronozm commented 3 months ago

One other minor comment -- I used tab-width as an argument to editorconfig in my commit addressing this issue. I wasn't sure if this is the best argument to use -- maybe someone more familiar with editorconfig could offer some insight.