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

Unable to define-key in company-active-map #63

Closed
naclander opened this issue Feb 8, 2017 · 9 comments
Closed

Unable to define-key in company-active-map #63

naclander opened this issue Feb 8, 2017 · 9 comments

Comments

@naclander
Copy link

After enabling company-quickhelp with

(company-quickhelp-mode 1)

The keybindings I set up in company-active-map don't seem to hold anymore. Specifically:

(define-key company-active-map (kbd "C-n") 'company-select-next-or-abort)
(define-key company-active-map (kbd "C-p") 'company-select-previous-or-abort)

Is this intended behavior? If so, do you know of a way around this issue?

@expez
Copy link
Collaborator

expez commented Feb 8, 2017

I don't know why this is happening to you. I have the following, in my .emacs,

(fill-keymap company-active-map
             "C-l" 'company-complete-common
             "C-k" 'company-complete-selection
             (kbd "TAB") 'yas-expand)

and it works fine.

@naclander
Copy link
Author

naclander commented Feb 9, 2017

I'm not familiar with fill-keymap, what does it do?

When company-quickhelp-mode is deactivated, the mapping works fine, so I am assuming this is some issue with quickhelp.

@expez
Copy link
Collaborator

expez commented Feb 9, 2017

I'm not familiar with fill-keymap, what does it do?

It's an abstraction living in my .emacs, but in this case all it does is make the appropriate calls to define-key, like in the example code you pasted above.

When company-quickhelp-mode is deactivated, the mapping works fine, so I am assuming this is some issue with quickhelp.

Reasonable assumption, but I can't reproduce.

If you set company-quickhelp-delay to some high value, like say 10 sec, are the keybindings working up to the point where company quickhelp comes to life? Or is it enough to just activate the mode?

@naclander
Copy link
Author

I added

(setq company-quickhelp-delay 10)

And like you said, the bindings work up until 10 seconds later, when the tooltip kicks in.

Are you saying you cannot reproduce this when you change your fill-keymap function directly to define-key?

@expez
Copy link
Collaborator

expez commented Feb 13, 2017

And like you said, the bindings work up until 10 seconds later, when the tooltip kicks in.

Aight, then what happens is that company-active-map stops being active when company-quickhelp creates a popup. Looking at the code in company this can happen if there's an error during its operation. Each such error is logged to the *messages* buffer. Do you see any error messages from company in that buffer?

Are you saying you cannot reproduce this when you change your fill-keymap function directly to define-key?

Yes

@naclander
Copy link
Author

I started typing something, waited for the tooltip to pop up, and then I started trying to iterate through the company-mode options using the "C-n" "C-p" mappings I had above. I see the following in the messsages buffer:

Type "q" in help window to delete it.
Scanning for dabbrevs...done
Expansion found in ‘*Help*’
Scanning for dabbrevs...done
user-error: No dynamic expansion for ‘company--electric-saved-window-configuration’ found
Scanning for dabbrevs...done
user-error: No dynamic expansion for ‘company--electric-saved-window-configuration’ found
Scanning for dabbrevs...done
user-error: No dynamic expansion for ‘company--electric-saved-window-configuration’ found

The alternating messages happen depending on whether i press "C-n" or "C-p". Also above, company--electric-saved-window-configuration was the option I was currently hovering over in company-mode. I'm not really sure what to make of these errors though.

@expez
Copy link
Collaborator

expez commented Feb 16, 2017

Aight, then this doesn't have anything to do with company-quickhelp. If you fix the errors (wherever they're coming from) you'll get the behavior you want.

@expez expez closed this as completed Feb 16, 2017
@twlz0ne
Copy link

twlz0ne commented Feb 25, 2017

Same issue here, and no error in *Messages* buffer.

The C-n and C-p works until quickhelp appears. But only occurs in emacs-lisp mode.

  • macOS 10.11
  • Emacs 25.2.1
  • Quickhelp 1.4.0

@twlz0ne
Copy link

twlz0ne commented Jul 2, 2017

I found the problem. because i binded C-n/p to evil-next/previous-visual-line in evil(inert state), there's a conflicat. my solution is:

(add-hook
 'company-completion-started-hook
 (lambda (&rest ignore)
   (when evil-mode
     (when (evil-insert-state-p)
       (define-key evil-insert-state-map (kbd "C-n") nil)
       (define-key evil-insert-state-map (kbd "C-p") nil)
       ))))

But why only emacs-lisp has this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants