Trigger Key Not Working in Yasnippet emacs
Asked Answered
A

1

6

Yasnippet seems to be working but the trigger key is not. I can load snippets, look at snippet tables and M-x yas/expand. However, after typing a trigger key (i.e time) I'd like to expand the snippet with the TAB key which isn't working. I checked the yasnippet.el file and found that the yas-trigger-key is set to . I tried changing it and still couldn't get it working. Anyone have an idea about what's going on? I'm trying to get this working first in LaTeX mode. Yasnippet tells me I should also try C-c C-s but that just seems to insert "\end."

I downloaded Yasnippet via the el-get packager manager. I'm using OSX and emacs 23.4.1

Adhesive answered 25/10, 2012 at 18:13 Comment(10)
Could you try M-x yas-expand RET (after your i.e. time)?Weissmann
Yup, that works fine...it just doesn't like tabAdhesive
Can you hit C-h k and then hit TAB? See what TAB is currently bound to (maybe it's not even TAB)?Weissmann
"TAB runs the command indent-for-tab-command, which is an interactive compiled Lisp function in `indent.el'...." it's now bound correctly. I tried to change it but it didn't work...Adhesive
Well, TAB is supposed to run yas-expand, and if there is nothing to expand, then it should do whatever the user has assigned to TAB. That is a matter of correctly installing yas though.Weissmann
Sorry, I meant it's not bound correctly. Weird. I can write "time", push tab, and nothing happens (I have yas-minor-mode enabled). I can then do M-x yas-expand and it gets expanded...Adhesive
So can you use "C-h k TAB" ? press those keys? See what it is bound and copy it here.Weissmann
TAB runs the command forward-button, which is an interactive compiled Lisp function in button.el'. It is bound to TAB. (forward-button N &optional WRAP DISPLAY-MESSAGE) Move to the Nth next button, or Nth previous button if N is negative. If N is 0, move to the start of any button at point. If WRAP is non-nil, moving past either end of the buffer continues from the other end. If DISPLAY-MESSAGE is non-nil, the button's help-echo string is displayed. Any button with a non-nil skip' property is skipped over. Returns the button found.Adhesive
'TAB (translated from <tab>) runs the command yas-expand, which is an alias for yas-expand-from-trigger-key' in yasnippet.el'. It is bound to TAB, <menu-bar> <YASnippet> <Expand trigger>. (yas-expand &optional FIELD) Expand a snippet before point. If no snippet expansion is possible, call command....'Weissmann
In other words, it isn't bound correctly.Weissmann
W
2
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

Did you put the aforementioned in your .emacs?

Maybe try reinstalling from this recent link

Weissmann answered 26/10, 2012 at 22:51 Comment(1)
I finally got it working by using hippie-expand. Thanks for taking the time to try and help. I found the following very helpful: gist.github.com/215930 . That's what I'm currently using and it seems to work...we'll see how it fares in the long run. Thanks again!Adhesive

© 2022 - 2024 — McMap. All rights reserved.