Enhanced-Ruby-Mode icon indicating copy to clipboard operation
Enhanced-Ruby-Mode copied to clipboard

Conflicts With YASnippet

Open JEG2 opened this issue 13 years ago • 6 comments

I simply love this mode and really want to use it all the time, but inserting snippets with YASnippet trips it up. Somehow, the initial snippet is not pushed down to the buffer. Because of that, the next change made indexes into the buffer string in bad spots. The parser recovers after the error, but the error is enough to cancel YASnippet's expansion, so they really don't peacefully coexist.

Ideally, it would be awesome to find a way to push down the YASnippet changes as they happen. If we can do that, this mode could keep parsing all the way through snippet expansion.

Another less ideal option is that YASnippet gives us before and after hooks. Is there someway I can disable the parser before expansion, then kick it back in after (somehow flushing the current buffer content to it)?

JEG2 avatar Sep 13 '12 16:09 JEG2

I was able to work around this issue with these hooks:

(add-hook 'yas/before-expand-snippet-hook
          (lambda ()
            (if (eq major-mode 'ruby-mode)
                (remove-hook 'after-change-functions #'erm-req-parse t))))
(add-hook 'yas/after-exit-snippet-hook
          (lambda ()
            (if (eq major-mode 'ruby-mode)
                (erm-reset-buffer))))

It's not ideal, but it seems to allow the two libraries to play together.

JEG2 avatar Sep 15 '12 18:09 JEG2

@JEG2 I am using this mode and yasnippets in version 0.7.0 and I'm not experiencing this problem. Maybe the culprit is something else in your setup?

asok avatar Oct 01 '12 20:10 asok

That's certainly possible, yes. I'll try to strip down my setup next time I have a chance to see if I can figure it out.

Just to be thorough though, did you test any multiline snippets with tab stops in them?

JEG2 avatar Oct 01 '12 21:10 JEG2

Yes multiline snippets with tab stops work for me.

asok avatar Oct 02 '12 18:10 asok

Good to know. Thanks.

JEG2 avatar Oct 02 '12 18:10 JEG2

I fixed this in the active fork. You can close this.

zenspider avatar Jan 04 '15 04:01 zenspider