Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive snippet-editing #41

Closed
joaotavora opened this issue Nov 3, 2011 · 7 comments
Closed

Recursive snippet-editing #41

joaotavora opened this issue Nov 3, 2011 · 7 comments
Assignees

Comments

@joaotavora
Copy link
Owner

It would be really nice to have yasnippet work recursively. That is, when
editing a snippet 'tab' would, instead of just skipping to the next
snippet, first try to see if there is a new snippet in the current field,
and if so, insert that and start a 'stacked' snippet editing process.

I dont know if it's clear what I mean, but maybe this use case explains it
better:

There's two snippets:
'if' inserts a regular 'if' statement
'testx' insert 'test_for_x()'

ideally, when I want to insert the code
if (test_for_x()) {
// do something
}

I would type 'if', press tab (inserts the 'if' snippet'), type 'testx',
press tab (would insert the 'x' snippet!), and press tab again would jump
inside the curly braces of the if, exiting the snippet.

Google Code Info:
Issue #: 38
Author: scherpenisse
Created On: 2008-10-10T15:09:25.000Z
Closed On: 2009-07-31T00:02:12.000Z

@ghost ghost assigned joaotavora Nov 3, 2011
@joaotavora
Copy link
Owner Author

Obviously, this is an enhancement, however the google interface won't allow me to
change the type...

Google Code Info:
Author: scherpenisse
Created On: 2008-10-10T15:10:26.000Z

@joaotavora
Copy link
Owner Author

Cool indeed.

Google Code Info:
Author: skaiuoq...@gmail.com
Created On: 2008-10-16T19:07:06.000Z

@joaotavora
Copy link
Owner Author

It will be great if this feature is supported.

Google Code Info:
Author: brian...@gmail.com
Created On: 2009-01-11T08:38:50.000Z

@joaotavora
Copy link
Owner Author

I think this feature is already supported. But I'm not sure it will work in all
situations, so I just disabled it by default. If you want to try it, just add this
after YASnippet initialization:

(define-key yas/keymap [tab] 'yas/expand)

However, since Emacs can't tell the difference between TAB and [tab] on a terminal, I
think this might not work properly inside a terminal.

Google Code Info:
Author: plus...@gmail.com
Created On: 2009-01-21T02:21:19.000Z

@joaotavora
Copy link
Owner Author

Another temp (and it usually works perfectly for me) is to bind expand to another key.

I bound yas/expand to C-RET, so, when i'm in snippet and i need to expand some small
snippet in it, i just press C-RET. As at expanding of snippet, C-RET sense don't
changed (as it done with TAB key), small snippet expands. Some kind of recursion.

Google Code Info:
Author: some.any...@gmail.com
Created On: 2009-03-05T17:40:01.000Z

@joaotavora
Copy link
Owner Author

I confirm that the recursive snippet-editing works great. Thanks.

I use hippie-expand and bind it to tab:

(setq hippie-expand-try-functions-list
(cons 'yas/hippie-try-expand hippie-expand-try-functions-list)))

And I use Enter/M-Enter to switch field:

;; reset yas/keymap
(setq yas/keymap (make-sparse-keymap))
(define-key yas/keymap (kbd "RET") 'yas/next-field-group)
(define-key yas/keymap (kbd "M-RET") 'yas/prev-field-group)

Google Code Info:
Author: zsle...@gmail.com
Created On: 2009-03-17T03:57:59.000Z

@joaotavora
Copy link
Owner Author

Already supported.

Also in new version 0.6.0, see also new customization variable `yas/triggers-in-field'.

Google Code Info:
Author: joaotav...@gmail.com
Created On: 2009-07-31T00:02:12.000Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant