minad / corfu

:desert_island: corfu.el - COmpletion in Region FUnction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when `global-corfu-modes` is not `t`

rrudakov opened this issue · comments

Steps to reproduce

  • emacs -q
  • evaluate the following in the *scratch* buffer:
(package-initialize)
(require 'corfu)
(setopt global-corfu-modes '((not eshell-mode)))
(global-corfu-mode 1)
  • Type part of some expression and execute cofru-complete.

Expected result

Popup with completion candidates is visible.

Actual result

Error:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  -(261 nil)
  (max 0 (- (point) beg))
  (let* ((pt (max 0 (- (point) beg))) (str (buffer-substring-no-properties beg end)) (metadata (completion-metadata (substring str 0 pt) table pred))) (let* ((val (completion-try-completion str table pred pt metadata))) (cond ((eq val 't) (let nil (goto-char end) (corfu--done str 'finished))) ((consp val) (let* ((x65 (car-safe val)) (x66 (cdr-safe val))) (let ((newstr x65) (newpt x66)) (if (equal str newstr) nil (completion--replace beg end ...)) (goto-char (+ beg newpt)) (if (and ... ...) (progn ...))))))))
  (if (>= corfu--index 0) (progn (corfu--insert nil) (let ((newstr (buffer-substring-no-properties beg end))) (if (and (test-completion newstr table pred) (or (not (consp ...)) (equal (completion-boundaries newstr table pred "") '...))) (progn (corfu--done newstr 'finished))))) (let* ((pt (max 0 (- (point) beg))) (str (buffer-substring-no-properties beg end)) (metadata (completion-metadata (substring str 0 pt) table pred))) (let* ((val (completion-try-completion str table pred pt metadata))) (cond ((eq val 't) (let nil (goto-char end) (corfu--done str 'finished))) ((consp val) (let* ((x65 ...) (x66 ...)) (let (... ...) (if ... nil ...) (goto-char ...) (if ... ...))))))))
  (let ((beg x57) (end x59) (table x61) (pred x63)) (if (>= corfu--index 0) (progn (corfu--insert nil) (let ((newstr (buffer-substring-no-properties beg end))) (if (and (test-completion newstr table pred) (or (not ...) (equal ... ...))) (progn (corfu--done newstr 'finished))))) (let* ((pt (max 0 (- (point) beg))) (str (buffer-substring-no-properties beg end)) (metadata (completion-metadata (substring str 0 pt) table pred))) (let* ((val (completion-try-completion str table pred pt metadata))) (cond ((eq val 't) (let nil (goto-char end) (corfu--done str ...))) ((consp val) (let* (... ...) (let ... ... ... ...))))))))
  (progn (ignore (null x64)) (let ((beg x57) (end x59) (table x61) (pred x63)) (if (>= corfu--index 0) (progn (corfu--insert nil) (let ((newstr (buffer-substring-no-properties beg end))) (if (and (test-completion newstr table pred) (or ... ...)) (progn (corfu--done newstr ...))))) (let* ((pt (max 0 (- ... beg))) (str (buffer-substring-no-properties beg end)) (metadata (completion-metadata (substring str 0 pt) table pred))) (let* ((val (completion-try-completion str table pred pt metadata))) (cond ((eq val ...) (let nil ... ...)) ((consp val) (let* ... ...))))))))
  (let* ((x63 (car-safe x62)) (x64 (cdr-safe x62))) (progn (ignore (null x64)) (let ((beg x57) (end x59) (table x61) (pred x63)) (if (>= corfu--index 0) (progn (corfu--insert nil) (let ((newstr ...)) (if (and ... ...) (progn ...)))) (let* ((pt (max 0 ...)) (str (buffer-substring-no-properties beg end)) (metadata (completion-metadata ... table pred))) (let* ((val ...)) (cond (... ...) (... ...))))))))
  (progn (ignore (consp x62)) (let* ((x63 (car-safe x62)) (x64 (cdr-safe x62))) (progn (ignore (null x64)) (let ((beg x57) (end x59) (table x61) (pred x63)) (if (>= corfu--index 0) (progn (corfu--insert nil) (let (...) (if ... ...))) (let* ((pt ...) (str ...) (metadata ...)) (let* (...) (cond ... ...))))))))
  (let* ((x61 (car-safe x60)) (x62 (cdr-safe x60))) (progn (ignore (consp x62)) (let* ((x63 (car-safe x62)) (x64 (cdr-safe x62))) (progn (ignore (null x64)) (let ((beg x57) (end x59) (table x61) (pred x63)) (if (>= corfu--index 0) (progn (corfu--insert nil) (let ... ...)) (let* (... ... ...) (let* ... ...))))))))
  (progn (ignore (consp x60)) (let* ((x61 (car-safe x60)) (x62 (cdr-safe x60))) (progn (ignore (consp x62)) (let* ((x63 (car-safe x62)) (x64 (cdr-safe x62))) (progn (ignore (null x64)) (let ((beg x57) (end x59) (table x61) (pred x63)) (if (>= corfu--index 0) (progn ... ...) (let* ... ...))))))))
  (let* ((x59 (car-safe x58)) (x60 (cdr-safe x58))) (progn (ignore (consp x60)) (let* ((x61 (car-safe x60)) (x62 (cdr-safe x60))) (progn (ignore (consp x62)) (let* ((x63 (car-safe x62)) (x64 (cdr-safe x62))) (progn (ignore (null x64)) (let (... ... ... ...) (if ... ... ...))))))))
  (progn (ignore (consp x58)) (let* ((x59 (car-safe x58)) (x60 (cdr-safe x58))) (progn (ignore (consp x60)) (let* ((x61 (car-safe x60)) (x62 (cdr-safe x60))) (progn (ignore (consp x62)) (let* ((x63 ...) (x64 ...)) (progn (ignore ...) (let ... ...))))))))
  (let* ((x57 (car-safe completion-in-region--data)) (x58 (cdr-safe completion-in-region--data))) (progn (ignore (consp x58)) (let* ((x59 (car-safe x58)) (x60 (cdr-safe x58))) (progn (ignore (consp x60)) (let* ((x61 (car-safe x60)) (x62 (cdr-safe x60))) (progn (ignore (consp x62)) (let* (... ...) (progn ... ...))))))))
  (progn (ignore (consp completion-in-region--data)) (let* ((x57 (car-safe completion-in-region--data)) (x58 (cdr-safe completion-in-region--data))) (progn (ignore (consp x58)) (let* ((x59 (car-safe x58)) (x60 (cdr-safe x58))) (progn (ignore (consp x60)) (let* ((x61 ...) (x62 ...)) (progn (ignore ...) (let* ... ...))))))))
  corfu-complete()
  funcall-interactively(corfu-complete)
  command-execute(corfu-complete record)
  execute-extended-command(nil "corfu-complete" "corfu-comp")
  funcall-interactively(execute-extended-command nil "corfu-complete" "corfu-comp")
  command-execute(execute-extended-command)

Screenshot

image

Related problem

Looks like type for defcustom global-corfu-modes is not entirely correct. When I'm trying to evaluate (setopt global-corfu-modes t) (back to the original value), I'm getting an error:

⛔ Warning (emacs): Value ‘t’ does not match type (repeat sexp)

I fixed the type error. I've not seen the other issue so far. Which Emacs version do you use?

Edit: Your usage of corfu is incorrect. You should invoke completion-at-point, not corfu-complete.

Right, sorry. If I use completion-at-point there is no error, but I see the default emacs completion, not corfu popup.

image

which is not what I expect to see. Are you able to reproduce it?

@minad should I provide any additional information? Or maybe I should create another issue? For some reason I cannot re-open this one.

That wasn't obvious :) Thank you for pointing it out.