Sublime Forum

Snippet Variables

#1

I have found lots of references to shellVariables and *.tmPreferences files when you want to create your own snippet variables.

What I haven’t found is a way to dynamically update those variables in a package before a snippet is triggered.

I have found view.meta_info(“shellVariables”,0) but setting the value in there doesn’t seem to impact the actual snippet expansion as far as I can tell.

Is there some way to update the shellVariables dynamically?
I am using snippets for capture templates in my OrgExtended but have a number of dynamic things I need to let the user add to their templates, fixing that up after snippet expansion is possible but hella ugly.

0 Likes

#2

its currently not possible to programmatically/dynamically set snippet variables. There are a few workarounds on this open feature request:

1 Like

#3

Thanks,
I didn’t know that with the insert_snippet call “additional parameters” became variables.
That is enough for my needs as I am inserting the snippets programmatically.

I am using snippets as the basis for my Org Mode “capture” system, IE: Press a keybinding you set up, a popup appears with a template you setup for that capture mode, dump whatever you care about in there, break out, it is automatically saved somewhere based on the capture template. (perhaps into a refile file or into a date tree in a worklog, or the actively clocked item etc) This is useful for taking notes during meetings or capturing some little chunk of code or whatever.

I needed a way to insert dates, but also things like the active clipboard, link to the active view before you spawned the capture and other surrounding text from where you started the capture, etc. The org mode capture system is quite flexible. I could write my own little template mechanism but I would rather just use snippets since my goal is to make this thing a 1st order sublime integration rather than forcing emacsisms into sublime.

Thank you very much for the pointer!

0 Likes