joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.81k stars 311 forks source link

Snippet broken after leaving snippet entry field #9

Closed joaotavora closed 13 years ago

joaotavora commented 13 years ago

What steps will reproduce the problem?

  1. Expand a snippet such as div for html-mode
  2. Move out of the snippet entry field using C-n or some such
  3. Try to expand an unrelated snippet

What is the expected output? What do you see instead? The second snippet should expand as normal but instead I get the error message "Not in a snippet field."

What version of the product are you using? On what operating system? 0.2.2 GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE

Please provide any additional information below.

Google Code Info: Issue #: 6 Author: andrew.g...@gmail.com Created On: 2008-03-13T17:45:16.000Z Closed On: 2008-03-15T10:43:02.000Z

joaotavora commented 13 years ago

This happens every time you hit TAB, actually, not just when on the second snippet. You have to kill the buffer and re-open it to get back on track (revert-buffer doesn't work).

GNU Emacs 22.1.90.1 (i386-mingw-nt6.0.6001) of 2008-02-05 on QUATRE

Google Code Info: Author: dereksla...@gmail.com Created On: 2008-03-13T18:37:40.000Z

joaotavora commented 13 years ago

In fact, as to the "div" snippet. You need to press TAB to exit the snippet instead of C-n. If you don't exit a snippet. The overlays will remain there (and maybe causing troubles).

Google Code Info: Author: plus...@gmail.com Created On: 2008-03-14T01:21:17.000Z

joaotavora commented 13 years ago

I know very little Lisp, so I'm sure this is a horrible solution, but I tried changing the code to try and expand again on tab, rather than sending out the error message. It seems to work in my tests.

Google Code Info: Author: jeffwheeler Created On: 2008-03-14T06:14:16.000Z

joaotavora commented 13 years ago

Ack, actually I think that may be causing weird recursion. I should have known. It works, but really, it is awful.

Google Code Info: Author: jeffwheeler Created On: 2008-03-14T06:18:45.000Z

joaotavora commented 13 years ago

When this happens, undoing to get back to either before you left the field or before you instantiated the snippet will get you out of this state.

Google Code Info: Author: tles...@gmail.com Created On: 2008-03-14T16:16:50.000Z

joaotavora commented 13 years ago

Hi jeffwheeler! I'm sorry I fixed it yesterday but forget to close this issue. I released another version(0.2.3) today (along with another bug fix). So you might want to try the new version.

BTW: I can't directly apply your patch, my code is changing and the line number might not be consistent during changes. You might want to create a patch with unified context next time. :) Try diff -Naur oldfile newfile > patch-file

Google Code Info: Author: plus...@gmail.com Created On: 2008-03-15T10:43:02.000Z

joaotavora commented 13 years ago

Oh, thanks pluskid--I didn't know about that option. Anyways, I suspect your solution is far better than my hack, so it's probably for the best. :P

Google Code Info: Author: jeffwheeler Created On: 2008-03-15T15:09:40.000Z

joaotavora commented 13 years ago

The new version is working amazingly well, I'm now fully moved over from tempo-mode. Awesome work!

Google Code Info: Author: dereksla...@gmail.com Created On: 2008-03-18T05:59:36.000Z