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

Suggestion: not preceded by space #1188

Open
davidpiano opened this issue Jan 29, 2024 · 4 comments
Open

Suggestion: not preceded by space #1188

davidpiano opened this issue Jan 29, 2024 · 4 comments

Comments

@davidpiano
Copy link

I've seen at least a couple of issues asking essentially the same thing: how to expand a key without putting a space before it, because the desired output must not contain a space at the place where the snippet is being added. Clearly, this isn't possible.

Obviously, a snippet replaces its key, and doesn't just appear beside the key; this means every snippet already deletes characters from the buffer.

Here's my suggestion: is there an easy way to make certain snippets delete one more character than they currently do? "Space-gobbling snippets" might solve a problem by removing the unwanted space after the fact.

@monnier
Copy link
Collaborator

monnier commented Jan 29, 2024 via email

@davidpiano
Copy link
Author

davidpiano commented Feb 2, 2024 via email

@monnier
Copy link
Collaborator

monnier commented Feb 3, 2024 via email

@ghost-of-freedom
Copy link

yas-key-syntaxes governs how the keys are ``gobbled''. It's a list where functions are called without arguments, and are expected to put the cursor at the start of the key, and strings are passed to skip-syntax-backwards. You can probably just make a function that saves the current point, goes back a word, gets the string between the two points, looks it up in a list or a table of keys that should have the space deleted, and if there's a match, backspaces a single character (which is assumed to be a space.) That should make yasnippet happy, because you put the cursor at the location of the start of the key, and you happy, because there's no space.

There might be an even better way of utilizing this variable, but this is the simplest solution that comes to mind.

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

3 participants