Emacs维基说:
公司确实干扰了Yasnippet的本土行为.这是一个快速修复:http: //gist.github.com/265010
代码如下:
(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)))
Run Code Online (Sandbox Code Playgroud)
我将该代码放在我的.emacs中,并显示以下消息:
Warning (initialization): An error occurred while loading `c:/Documents and Settings/Alex.AUTOINSTALL.001/Application Data/.emacs.elc':
Symbol's 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.
Run Code Online (Sandbox Code Playgroud)
我是否必须将修复代码放在YASnippet的.el文件中?或者在我的.emacs中(这会引发错误)?
无论如何,您提到的代码段不再有效。
这是您可以使用的代码段:
(defun company-yasnippet-or-completion ()
(interactive)
(let ((yas-fallback-behavior nil))
(unless (yas-expand)
(call-interactively #'company-complete-common))))
Run Code Online (Sandbox Code Playgroud)
要确保调用 this 而不是company-complete-common
,请使用
(add-hook 'company-mode-hook (lambda ()
(substitute-key-definition 'company-complete-common
'company-yasnippet-or-completion
company-active-map)))
Run Code Online (Sandbox Code Playgroud)
背景:这会在本地更改 的值yas-fallback-behaviour
,company-complete-common
如果未找到完成,则会导致 yas 调用。
all*_*aws -3
这听起来像是加载路径的问题。符号值为 void 意味着 emacs 找不到它的定义 - 很可能是因为包含其定义的文件尚未加载。
您可以尝试在 .emacs 中添加类似的内容(在导致错误的代码之前):
;; 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/")
Run Code Online (Sandbox Code Playgroud)