tumashu / company-posframe

121 stars 24 forks source link

Recent code seems "break" the nice code that uses numbers to select candidates. #23

Closed yanghaoxie closed 4 years ago

yanghaoxie commented 4 years ago

I have nice code borrows from abo-abo that makes it possible to use numbers to select candidates, however recent code seems "break" it. I tried to resolve this issue, but failed. Could you please have a look at this?

The error message is as follows,

Company: An error occurred in pre-command
Company: frontend company-pseudo-tooltip-unless-just-one-frontend error "Wrong type argument: symbolp, (lambda nil (interactive) (company-abort) (self-insert-command 1))" on command pre-command
Error in pre-command-hook (company-pre-command): (error "Company: frontend company-pseudo-tooltip-unless-just-one-frontend error \"Wrong type argument: symbolp, (lambda nil (interactive) (company-abort) (self-insert-command 1))\" on command hide")
company-call-frontends: Company: frontend company-pseudo-tooltip-unless-just-one-frontend error "Wrong type argument: symbolp, (lambda nil (interactive) (company-abort) (self-insert-command 1))" on command hide
tumashu commented 4 years ago

Please try newest version

tumashu commented 4 years ago

I have tested in my machine in newest company-posframe, not found this problem

yanghaoxie commented 4 years ago

Sorry, I did not explain the issue rightly. The error only occurs when you hit space while there is a list of candidates showing up. If you hit a number to select on candidate, there is no error. I still have this issue with the newest version.

tumashu commented 4 years ago

hit "space" to insert space? you can try:

(defun my-space ()
  (interactive)
  (company-abort)
  (self-insert-command 1))

(let ((map company-active-map))
  (mapc (lambda (x) (define-key map (format "%d" x) 'ora-company-number))
        (number-sequence 0 9))
  (define-key map " " 'my-space)
  (define-key map (kbd "<return>") nil))
yanghaoxie commented 4 years ago

Thank you very much! It works. It seems like the problem is due to the lambda function?

tumashu commented 4 years ago

yes, argument require symbol, while lambda form is not symbol

yanghaoxie commented 4 years ago

Sounds cool although I do not really know what is going on (不明觉厉). Thanks again!. :smiley: