Hospitalist/programmer in search of the meaning of life

Emacs Autocomplete Stumbles on Yasnippet

Oct 15th, 2012

Autocomplete Mode is an
Emacs mode that tries to guess what word you’re typing and provide
auto-completion. Recently, it started failing in simple scenarios.

It can use various ‘sources’ to try to figure out what you’re about to
type. The simplest source is ac-source-dictionary which is a simple
list of words. If you start typing any of those words, it will try to
autocomplete them for you. Normally, you’d put those words in a file,
with each word on a separate line, but for testing purposes, you can
also add them manually using an elisp function. Here’s the test that
failed for me:

So, autocomplete is looking through each one of those sources, trying
to find possible words I might be typing. The third one is called
ac-source-yasnippet, which seems to be where my error is coming
from.

So, I looked into the yasnippet source code and found that, indeed,
there was no function named yas/current-snippet-table. That function
has been renamed to yas--get-snippets-table in version 0.8.0, but
autocomplete is still relying on the old function name. (RANT: Don’t
rename functions that others might be using without providing some
kind of alias, at least temporarily) I looked at the code for
autosnippet on github
and noted that the latest version has been fixed to use the new code,
but it hasn’t yet been released on MELPA. Until it is, the quick
solution is to remove ac-source-yasnippet from ac-sources.

It seems that autocomplete should be more forgiving of errors in any
specific ‘source’, passing it up to use other sources. Alternatively,
it should fail loudly when there’s an error, so that I can know to fix
or remove the offending ‘source’.