Skip to content

Instantly share code, notes, and snippets.

@sebastiencs
Created June 15, 2017 23:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sebastiencs/a16ea58b2d23e2ea52f62fcce70f4073 to your computer and use it in GitHub Desktop.
Save sebastiencs/a16ea58b2d23e2ea52f62fcce70f4073 to your computer and use it in GitHub Desktop.
company with yasnippet
;; With this code, yasnippet will expand the snippet if company didn't complete the word
;; replace company-complete-common with company-complete if you're using it
(advice-add 'company-complete-common :before (lambda () (setq my-company-point (point))))
(advice-add 'company-complete-common :after (lambda ()
(when (equal my-company-point (point))
(yas-expand))))
@ianyepan
Copy link

ianyepan commented Jan 3, 2020

To avoid the "assignment to free variable" warning, one could add (defvar my-company-point nil) above the snippet.

@paxperscientiam
Copy link

This actually works. Wow -- thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment