jacott / Enhanced-Ruby-Mode

An enhanced ruby-mode for Emacs that uses Ripper in ruby 1.9.2 to highlight and indent the source code
Other
53 stars 64 forks source link

Conflicts With YASnippet #17

Open JEG2 opened 12 years ago

JEG2 commented 12 years ago

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 commented 12 years ago

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.

asok commented 11 years ago

@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?

JEG2 commented 11 years ago

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?

asok commented 11 years ago

Yes multiline snippets with tab stops work for me.

JEG2 commented 11 years ago

Good to know. Thanks.

zenspider commented 9 years ago

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