About eliminating interference between company mode and Yasnippet

Emacs wiki says:

The company is really interfering with Yasniptsy native behavior. Has a quick fix: http://gist.github.com/265010

The code is as follows:

(define-key company-active-map "\t" 'company-yasnippet-or-completion) (defun company-yasnippet-or-completion () (interactive) (if (yas/expansion-at-point) (progn (company-abort) (yas/expand)) (company-complete-common))) (defun yas/expansion-at-point () "Tested with v0.6.1. Extracted from `yas/expand-1'" (first (yas/current-key))) 

I put this code in my .emacs and the following message appeared:

 Warning (initialization): An error occurred while loading `c:/Documents and Settings/Alex.AUTOINSTALL.001/Application Data/.emacs.elc': Symbol value as variable is void: company-active-map To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace. 

Should I put the patch code in the YASnippet.el file? or in my .emacs (which causes me an error)?

+7
plugins emacs
source share
2 answers

The mentioned fragment does not work in any case.

Here is a snippet you can use instead:

 (defun company-yasnippet-or-completion () (interactive) (let ((yas-fallback-behavior nil)) (unless (yas-expand) (call-interactively #'company-complete-common)))) 

To make sure this is called instead of company-complete-common , use

 (add-hook 'company-mode-hook (lambda () (substitute-key-definition 'company-complete-common 'company-yasnippet-or-completion company-active-map))) 

Background: this locally changes the value of yas-fallback-behaviour , which causes yas to call company-complete-common if no completion is found.

+3
source share

This seems like a boot problem. The value of the void character means that emacs cannot find a definition for it - most likely, since the file containing its definition is not yet loaded.

You can try adding something like this in your .emacs (before the error code):

 ;; where ~/.emacs.d/ is the path to a directory containing ;; additional library code you want emacs to load (add-to-list 'load-path "~/.emacs.d/") 
-2
source share

All Articles