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

Alternative to multiple keys for one template #375

Open
magnars opened this issue May 1, 2013 · 3 comments
Open

Alternative to multiple keys for one template #375

magnars opened this issue May 1, 2013 · 3 comments

Comments

@magnars
Copy link

magnars commented May 1, 2013

Good day,

What I am trying to achieve is that I have a template that can either be expanded by typing a complete mnemonic shortcut (say ascn for assert.className), or to just type a common root to get a list of suggestions (say as to get a list of all assertions).

The simplest way of fixing that in my mind would be to allow multiple keys. But as I can tell from the yasnippet source code, it might be an extensive job to make that happen.

So, do you have any suggestions on how to do it? Maybe I should programmatically create the snippets instead, and register two snippets per template?

@joaotavora
Copy link
Owner

Hi Magnar,

I'll try to analyse this issue more carefully, but it also springs to mind that you can make a ascn snippet expand to assert.classname. Hitting the trigger key twice in a row would give you the desired behaviour. You can also make ascn be a snippet-command consisting of elisp that inserts that text then calls yas-expand automatically. Snippet-commands are the ones using # type: command, unfortunately very undocumented except for informal issue replies and emails to the list.

As for the as suggestion, maybe you can use auto-complete, which is a completion framework. Yasnippet is a template expansion framework, with some menus to resolve ambiguity, some of which operate through completion backends like ido-completing-read. I agree that in this last part there is some overlap.

Anyway, I will try to analyse your request, time permitting. Patches and bold redesign attempts are welcome though.

J

@npostavs
Copy link
Collaborator

The simplest way of fixing that in my mind would be to allow multiple keys. But as I can tell from the yasnippet source code, it might be an extensive job to make that happen.

See also #114.

@zw963
Copy link

zw963 commented Jun 17, 2016

This is a very desirable feature for me too. #342 exist a example for this.

It seem like it still not worked ...

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

No branches or pull requests

4 participants