-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
Helm capf does not call exit-function #2265
Comments
Ivan Yonchovski <notifications@github.com> writes:
Expected behavior
helm calls :exit-function
No.
helm does not call exit function
:exit-function is only needed for the emacs vanilla completion UI,
i.e. "*completions*" buffer, so yes helm doesn't handle it, though it
handle :annotation-function.
What do you want do do exactly?
…--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
|
:exit-function is used by the backends (capf functions) to perform post-completion processing(e. g. expanding snippets). ATM the only frontend that does not call :exit-function is helm. It works fine with company-capf, ivy and vanilla. The result is that helm capf frontend does not work with lsp-mode(and probably all other backends that perform post-completion). |
Ivan Yonchovski <notifications@github.com> writes:
:exit-function is used by the backends (capf functions) to perform
post-completion processing(e. g. expanding snippets). ATM the only
frontend that does not call :exit-function is helm. It works fine with
company-capf, ivy and vanilla. The result is that helm capf frontend
does not work with lsp-mode(and probably all other backends that
perform post-completion).
Thanks for explanation, is this working for you?
diff --git a/helm-mode.el b/helm-mode.el
index cb75b989..0dd9e32c 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -1674,7 +1674,8 @@ Can be used for `completion-in-region-function' by advicing it with an
(advice-add
'lisp--local-variables
:around #'helm-mode--advice-lisp--local-variables)
- (let ((old--helm-completion-style helm-completion-style))
+ (let ((old--helm-completion-style helm-completion-style)
+ string)
(helm-aif (cdr (assq major-mode helm-completion-styles-alist))
(customize-set-variable 'helm-completion-style
(if (cdr-safe it) (car it) it)))
@@ -1682,7 +1683,7 @@ Can be used for `completion-in-region-function' by advicing it with an
(let* ((enable-recursive-minibuffers t)
(completion-flex-nospace t)
(completion-styles (helm--prepare-completion-styles))
- (input (buffer-substring-no-properties start end))
+ (input (setq string (buffer-substring-no-properties start end)))
;; Always start with prefix to allow completing without
;; the need of inserting a space after cursor or
;; relaying on crap old completion-styles emacs22 which
@@ -1818,6 +1819,7 @@ Can be used for `completion-in-region-function' by advicing it with an
t) ; exit minibuffer immediately.
:must-match require-match))))
(helm-completion-in-region--insert-result result start point end base-size))
+ (completion--done string 'finished)
(customize-set-variable 'helm-completion-style old--helm-completion-style)
(setq helm-completion--sorting-done nil)
(advice-remove 'lisp--local-variables
…--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
|
If you can provide a recipe on how to reproduce with lsp-mode it is perfect ;-) Note: I know nothing about lsp-mode and how to make it working (dependencies etc..). |
Thank you for the quick reply, I will test it on my side and report back. |
Using the patch from above I get an error in |
Ivan Yonchovski <notifications@github.com> writes:
Using the patch from above I get an error in lsp-mode since it is
called with candidate = "" (in your case the string param in
completion--done). I would expect completion--done to be called with
the selected candidate as it was generated from the capf function
since we encode properties in it.
Ok, thanks, here the modified patch.
diff --git a/helm-mode.el b/helm-mode.el
index cb75b989..3cdb81af 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -1674,7 +1674,8 @@ Can be used for `completion-in-region-function' by advicing it with an
(advice-add
'lisp--local-variables
:around #'helm-mode--advice-lisp--local-variables)
- (let ((old--helm-completion-style helm-completion-style))
+ (let ((old--helm-completion-style helm-completion-style)
+ string)
(helm-aif (cdr (assq major-mode helm-completion-styles-alist))
(customize-set-variable 'helm-completion-style
(if (cdr-safe it) (car it) it)))
@@ -1817,7 +1818,9 @@ Can be used for `completion-in-region-function' by advicing it with an
(message "[No matches]")))
t) ; exit minibuffer immediately.
:must-match require-match))))
+ (setq string result)
(helm-completion-in-region--insert-result result start point end base-size))
+ (completion--done string 'finished)
(customize-set-variable 'helm-completion-style old--helm-completion-style)
(setq helm-completion--sorting-done nil)
(advice-remove 'lisp--local-variables
…--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
|
I tested the last patch - the candidate text is the correct one but the text properties are stipped. |
Ivan Yonchovski <notifications@github.com> writes:
I tested the last patch - the candidate text is the correct one but
the text properties are stipped.
Yes text properties are always stripped, at least in helm-mode.
So what you are expecting is much harder to fix (I mean to fix without
breaking everything else).
…--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
|
* helm-mode.el (helm--completion-in-region): Call completion--done at end.
Isn't it possible to fix only this source to provide a lookup and allow finding the original item without changing the helm core stuff? Another option is to do that on our side via hacky buffer-local variable solution to do the same. And the third option is to declare/document both helm capf and lsp-mode incompatible. |
Ivan Yonchovski <notifications@github.com> writes:
Isn't it possible to fix only this source to provide a lookup and
allow finding the original item without changing the helm core stuff?
Kind of, this is what I am working on.
…--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
|
* helm-mode.el (helm-completion-in-region-selection): New. (helm--completion-in-region): Use it in helm-before-action-hook.
Can you try last changes? |
Merged to master. |
I can confirm that it works fine. Thank you. |
Allow running extra property :exit-function (Issues #2265, #2356). Passing 'finished to `completion--done' is probably the more logical as completion is always finished in our case when pressing RET, at one point 'finished was addind a space at insertion so we used 'exact, but it seems it is no more the case.
Expected behavior
helm calls :exit-function
Actual behavior (from
emacs-helm.sh
if possible, see note at the bottom)helm does not call exit function
Steps to reproduce (recipe)
Describe versions of Helm, Emacs, operating system, etc.
Latest from melpa, emacs 27/26 . Linux.
Are you using
emacs-helm.sh
to reproduce this bug? (yes/no):No, but reproduced in clean env with
Are you using Spacemacs? (yes/no):
No.
The text was updated successfully, but these errors were encountered: