Skip to content
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

Closed
yyoncho opened this issue Jan 20, 2020 · 14 comments
Closed

Helm capf does not call exit-function #2265

yyoncho opened this issue Jan 20, 2020 · 14 comments
Labels

Comments

@yyoncho
Copy link

yyoncho commented Jan 20, 2020

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)

(defun bug-completion-at-point ()
  (list
   (point)
   (point)
   (completion-table-dynamic (lambda (&rest _)
                               (list "foobar"
                                     "foobar2")))
   :exit-function (lambda (candidate _status)
                    (debug))))
(setq-local completion-at-point-functions (list 'bug-completion-at-point))

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.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Jan 20, 2020 via email

@yyoncho
Copy link
Author

yyoncho commented Jan 20, 2020

: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).

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Jan 20, 2020 via email

@thierryvolpiatto
Copy link
Member

If you can provide a recipe on how to reproduce with lsp-mode it is perfect ;-)
At least with the recipe you sent and the patch above applied, the exit fn is called.

Note: I know nothing about lsp-mode and how to make it working (dependencies etc..).
Thanks.

@yyoncho
Copy link
Author

yyoncho commented Jan 20, 2020

Thank you for the quick reply, I will test it on my side and report back.

@yyoncho
Copy link
Author

yyoncho commented Jan 20, 2020

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.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Jan 20, 2020 via email

@yyoncho
Copy link
Author

yyoncho commented Jan 21, 2020

I tested the last patch - the candidate text is the correct one but the text properties are stipped.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Jan 21, 2020 via email

thierryvolpiatto pushed a commit that referenced this issue Jan 21, 2020
* helm-mode.el (helm--completion-in-region): Call completion--done at end.
@yyoncho
Copy link
Author

yyoncho commented Jan 21, 2020

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.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Jan 22, 2020 via email

thierryvolpiatto pushed a commit that referenced this issue Jan 22, 2020
* helm-mode.el (helm-completion-in-region-selection): New.
(helm--completion-in-region): Use it in helm-before-action-hook.
@thierryvolpiatto
Copy link
Member

Can you try last changes?

@thierryvolpiatto
Copy link
Member

Merged to master.

@yyoncho
Copy link
Author

yyoncho commented Jan 22, 2020

I can confirm that it works fine. Thank you.

@yyoncho yyoncho closed this as completed Jan 22, 2020
thierryvolpiatto pushed a commit that referenced this issue Aug 7, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants