0

I'm frustrated with the default behavior of autocomplete overriding key bindings used by yasnippets.

Is there a way to set a precedence so that tab will try to expand a snippet before trying to autocomplete the word?

Quick disclosure: I'm using evil-mode.

event_jr
  • 17,467
  • 4
  • 47
  • 62
Brandon
  • 3,573
  • 6
  • 19
  • 21

1 Answers1

3

If they're both minor modes, then precedence is determined by the order of elements in minor-mode-map-alist which, unless explicitly manipulated, is simply determined by the order in which the libraries were loaded.

Ensure that autocomplete is loaded before yasnippet, and yasnippet's minor mode map would have precedence.

You could also use eval-after-load to adjust minor-mode-map-alist after loading autocomplete, to check for a yasnippet entry, and re-order the list if necessary.

(autocomplete may use other methods, though. A temporary overriding keymap would still have precedence over the minor mode maps, for instance.)

phils
  • 71,335
  • 11
  • 153
  • 198
  • Could you provide an example of how to re-order the list? I tried to delete yasnippet's and then append back (hopefully at the end of the list) yasnippet with eval-after-load with autocomplete, but my delete operation with the following code: (setq minor-mode-alist (delete '(yasnippet keymap) minor-mode-alist)) but the keymap for yasnippet was not deleted. – Yu Shen Aug 22 '17 at 17:41
  • 1
    (1) `minor-mode-map-alist`, not `minor-mode-alist`. (2) See an example at https://stackoverflow.com/a/5340797 – phils Aug 22 '17 at 21:14