-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using completion-preview-mode
and completion-preview-complete
#664
Comments
I see in the documentation to |
It appears that `sly--completion-in-region-function` expects a function as
its third argument but is given a list of matches here.
That arg is often a function but can be any completion table, so I think
a patch like the one below is needed [too bad GitHub is too stupid to
accept Markdown over email. It could learn something from Gitlab in
this respect].
Stefan
```
diff --git a/lib/sly-completion.el b/lib/sly-completion.el
index d3bfcf029a..9cbec4ba79 100644
--- a/lib/sly-completion.el
+++ b/lib/sly-completion.el
@@ -362,9 +362,10 @@ Intended to go into `completion-at-point-functions'"
sly-complete-symbol))
(add-function :around (local 'completion-in-region-function)
(lambda (oldfun &rest args)
- (if sly-symbol-completion-mode
- (apply #'sly--completion-in-region-function args)
- (apply oldfun args)))
+ (apply (if sly-symbol-completion-mode
+ #'sly--completion-in-region-function
+ oldfun)
+ args))
'((name . sly--setup-completion))))
(define-minor-mode sly-symbol-completion-mode "Fancy SLY UI for Lisp symbols" t
@@ -384,7 +385,8 @@ Intended to go into `completion-at-point-functions'"
;;;
(defun sly--completion-in-region-function (beg end function pred)
(cond
- ((funcall function nil nil 'sly--identify)
+ ((and (functionp function)
+ (funcall function nil nil 'sly--identify))
(let* ((pattern (buffer-substring-no-properties beg end))
(all
(all-completions pattern function pred))
```
|
@monnier since it's your patch, I'd suggest you moving forward. Let me know. |
I applied this change locally and it will keep things from erroring. However won't this circumvent all the nice features of |
It might. You're the only one testing it, afaik. Can you tell us which features you suspect or observe being circumvented? |
I gave it a quick test:
It seems to me that the modified function is good, as it allows for completion to work well with |
This is a no-go, unless this behaviour is recovered when completion-preview-mode is turned off again. |
IOW, people using SLY as they have been for many years shall not be impacted by this patch. |
Sorry to cause confusion. The behavior appears to be the normal |
* lib/sly-completion.el (sly--setup-completion): Move the advice's wrapper into `sly--completion-in-region-function`. (sly--completion-in-region-function): Add `orig-fun` and `rest` args. Rename `function` to `collection`. Test `sly-symbol-completion-mode` and make sure `collection` is a function before using it as such.
@monnier why did you push to |
@monnier why did you push to `sly/master` instead of `master`?
Oops. Should be fixed now, thanks.
|
Minimal replication with emacs -Q (assuming sly installed at "~/.emacs/elpa/sly-20240809.2119")
Evaluate
Then type
(form
into the REPL - completion-preview-mode will show first possible match, usecompletion-preview-complete
(bound toM-i
by default) to list all completions and get the following backtrace:It appears that
sly--completion-in-region-function
expects a function as its third argument but is given a list of matches here.What is the responsibility of this function argument? I am thinking I might at least hack together a fix with an advice...
The text was updated successfully, but these errors were encountered: