Jump to content
csaborio

Feature Request : Interactive Variables for Snippets

Recommended Posts

Not sure if this has been requested, but I was dissapointed to see that the "Snippets" feature was not touched in this last 4.0 update.

I would love to be able to create snippets that interacted and requested info based on how you define it.

 

For instance, if my snippet is defined as: "Your name is %name%", when executed, a prompt will request the %name% value and then paste the shortcut --> "Your name is Christian".

I am trying to use RocketTypist to do this but it's buggy, this would be a nice addition to the snippet feature in Alfred, which I have found to be very responsive.

 

Thanks! 

Share this post


Link to post
Share on other sites

@csaborio Snippets have had significant improvements in Alfred 4, including rich text snippets. Rather than start a post with "I was disappointed", how about simply asking whether it's possible to do X? :) 

 

Take a look at this post, which shows some of the ways you can use Snippet Triggers and workflows to add dynamic placeholders into a snippet on the fly:

https://www.alfredapp.com/help/workflows/triggers/snippet/snippet-triggers-with-dynamic-inputs/

 

trigger-hello-ellie.png

 

There are many other ways to include dynamic placeholders, clipboard content, pasteboard content, variables, randomly selected items from a list, etc into your snippets so this is just one of the may ways to add in content.

 

Here's where you can find out more about Dynamic Placeholders:

https://www.alfredapp.com/help/workflows/triggers/snippet/snippet-triggers-with-dynamic-inputs/

 

Cheers,
Vero

Share this post


Link to post
Share on other sites

Hi Vero,

 

Thanks for the reply. My apologies for sounding a bit negative, but I've been juggling between Rocket Typist, Dash's code snippets and Alfred's snippets without any luck for some time.

 

It seems to me a lot of work went into Alfred to make workflow creation easier and more robust, but snippets were left out in the cold.

The dynamic placeholders within workflows seems to be the only way to achieve what I would need, but that means creating a workflow every time I need a snippet. The thought of organising my workflows that use dynamic placeholders is just mind-boggling.

 

I think I'll just have to ante up and buy TextExpander.

 

Appreciate your feedback and links.

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
7 hours ago, csaborio said:

It seems to me a lot of work went into Alfred to make workflow creation easier and more robust, but snippets were left out in the cold.

 

This feature has been requested multiple times. So, it's not looking great…

 

7 hours ago, csaborio said:

The thought of organising my workflows that use dynamic placeholders is just mind-boggling.

 

Yeah, I'm not sure the Alfred team really appreciate how completely impractical this is. What takes 20 seconds in Typinator/TextExpander/aText takes 20 minutes in Alfred.

 

And Alfred's UI is a poor fit for the job, too (you can't tab back and forth between fields the way you can in an application with support for real fill-in snippets).

Edited by deanishe

Share this post


Link to post
Share on other sites
11 hours ago, deanishe said:

Yeah, I'm not sure the Alfred team really appreciate how completely impractical this is. What takes 20 seconds in Typinator/TextExpander/aText takes 20 minutes in Alfred.

 

Don't forget that this is the ONLY thing the apps you mention do. For Alfred, it is ONE part of a larger feature set.

 

While things like this may come to Alfred in the future, there is a much bigger picture here.

Share this post


Link to post
Share on other sites
Just now, Andrew said:

Don't forget that this is the ONLY thing the apps you mention do. For Alfred, it is ONE part of a larger feature set.

 

That's understood.

 

To be clear, I'm not complaining about the lack of the feature, I'm questioning the value of suggesting Snippet Triggers as an alternative to the fill-in snippets offered by other snippet apps.

 

They are a poor fit for this task (UX, comparatively enormous effort), even if they can technically be used to achieve the desired results.

Share this post


Link to post
Share on other sites

Yes, I second deanishe..the idea of using snippet triggers is not a good alternative, at least not for me. On top of the reasons listed above, you also have to think of being able to export these things to work with another platform if you choose to go with another product in the future and, (AFAIK) snippet triggers can't easily be exported to be imported into another macro-like program

 

I've done a bit of research and for my purposes (web code snippets with variable placeholders) Dash is the best choice out there, also gives you amazing offline documentation.

Share this post


Link to post
Share on other sites

This all seems a bit overblown.  I converted +/- 35 complex (i.e. not just a string) TextExpander snippets when I moved to Alfred & as I recall the whole process was maybe 2 hours.  Most of these were AppleScript-based snippets on TE.  These are clustered in 7 different workflows (you do understand that you don't need one workflow per snippet trigger, right?).

 

Once you've created the 'Ellie' example above, adding new snippets is simply a matter of copying and pasting that prototype (or another) within your workflow then editing the text. 

 

By all means use Dash if it works for you.  But based on the linked docs it's a pretty basic implementation of snippets, without even the most basic of automation (e.g. no date math).  Alfred can do way, way more once you start linking snippet triggers to list filters and script filters.  I use these to pull data from BibDesk and Filemaker databases, which wasn't possible with TE and certainly wouldn't be with Dash.

 

Share this post


Link to post
Share on other sites
Posted (edited)
11 hours ago, dfay said:

Alfred can do way, way more once you start linking snippet triggers to list filters and script filters.

 

Sure, but it does a crap job of fill-in snippets, which is what this thread is about.

 

EDIT: I think I've been talking about something different to everybody else. Alfred is fine for inserting a single placeholder. It's a bad fit for multiple placeholders, however, which is what I fundamentally associate fill-in snippets with.

Edited by deanishe

Share this post


Link to post
Share on other sites

Ok I was addressing the subject line “Interactive Variables” which can encompass a lot more than simple fill-ins.  

 

But, to stick with fill-ins, what’s so hard about duplicating a prototype then changing the text?  I think this is preferable in that it keeps a consistent architecture, rather than using a set of text delimiters to launch Alfred for input, which is not done anywhere else.  

 

And it makes it easier to turn a simple fill-in into something more complex.  A lot of my snippet triggered filters began as fill-ins then I realized it made more sense to choose from a finite list and/or search output.  This seems particularly desirable in a web development environment to e.g. insert a div but limit the classes to those defined in a list filter (or even use a script filter to parse the css ... ).

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
2 hours ago, dfay said:

But, to stick with fill-ins, what’s so hard about duplicating a prototype then changing the text?

 

The problem is that many fill-in snippets have multiple placeholders, which is where Alfred is weak. If you only have one placeholder, and it doesn't need to be inserted in multiple places, you can usually just use the cursor macro instead. @csaborio's and @Vero's examples would both work fine with cursor positioning.

 

Here's one of my Markdown fill-ins from Typinator:

 

---
title: {{?Title}}
date: {YYYY}-{MM}-{DD}
draft: {{?Draft<false>}}
tags: {{?Tags}}
partner: {{?Partner}}
---
{^}
<!--more-->

 

There are four placeholders there. To implement that with Snippet Triggers, I'd need to add a Keyword + Args & Vars for each placeholder. That's a lot of work compared to typing a few curly braces.

 

Here's the Typinator UI:

image.png.1a5bcb381ef81470b03d2908993ba535.png

You can tab back and forth between the fields (in case you made a typo). You can leave the window to copy some text from somewhere else and it won't disappear.

 

With Alfred, you have to pop up the query box for each field in turn, and there's no going back or leaving the app. If you don't get it right first time, you have to start over.

 

You can do some amazing stuff with Snippet Triggers, but they are not well suited to this particular task.

 

2 hours ago, dfay said:

This seems particularly desirable in a web development environment to e.g. insert a div but limit the classes to those defined in a list filter (or even use a script filter to parse the css ... ).

 

For development, I'd generally recommend using your editor's built-in snippet engine rather than a separate application. They typically work much better because they are aware of things like indentation level, which an external application like Alfred couldn't possibly know.

Edited by deanishe

Share this post


Link to post
Share on other sites
Posted (edited)

FWIW, I've been thinking about how to implement fill-in snippets well in Alfred for some time, as I'd like to ditch Typinator (I only use it for fill-ins).

 

I think Pashua would be a good fit for the UI. You could generate workflow variables from its output, then use Alfred's Copy to Clipboard to insert them into your snippet.

 

The trick is specifying which things to ask for in a sensible way.

 

So far I've considered parsing info.plist to figure out which Copy to Clipboard the currently-running script is attached to and extracting the {var:...} placeholders from it.

 

Alternatively, the snippet could be defined in an Args & Vars element upstream of the input and inserted into the Copy to Clipboard via a JSON Config.

 

EDIT: Here's a demo of my ghetto prototype:

 

fill-ins.gif.c8ff0c6b4608f55a297682e99b8c2175.gif

Edited by deanishe

Share this post


Link to post
Share on other sites
Posted (edited)
14 hours ago, dfay said:

Point re complexity with multiple variables is well-taken.

 

I think we've been talking past one another. Or I've been talking past everyone else…

 

I fundamentally associate fill-ins with multiple placeholders because I consider that their raison d'être. They're also useful if you need to insert a single value in multiple places (which Alfred can do just fine), but otherwise {cursor} is sufficient for a single placeholder.

 

14 hours ago, dfay said:

Yeah I thought of Pashua when I saw your post.

 

Pashua is awesome!

 

Have you got any ideas about how to wire it into Alfred snippets?

 

Ideally, you'd just need to copy the line of elements and edit the trigger and snippet.

 

With my current implementation, you also have to edit the Run Script node to tell the script which variables to ask for. That kinda sucks.

Edited by deanishe

Share this post


Link to post
Share on other sites
On 7/3/2019 at 5:11 PM, csaborio said:

 am trying to use RocketTypist to do this but it's buggy

 

 

I know this is an Alfred forum and I don’t mean to hijack to talk another product (though I am going to), but googling “Rocket Typist buggy” led me here. I use text expansion for work (not programming) and started using RT. That app is so buggy it’s downright unusable. I’ve sent the developer multiple messages over the course of 7-8 days and haven’t received a single reply, so I’m left with looking for user feedback to see if they’ve had a similar experience. 

 

1. Crashes. During snippet creation (I have close to 450), the apps crashed dozens of times. 

2. If the snippet editor window is open and a snippet is triggered (within RT or in a third party app), the snippet editor window closes and reopens on its own. 

3. iCloud syncing is a mess. It took me forever to create those ~450 snippets on my iMac. When I enabled iCloud sync on my MacBook Pro, many of them were missing entirely while many others were missing their abbreviations, snippet text or labels. Also, the names for some of the folders I created didn’t carry over either, and the name was reset to “untitled”.

 

Since you mentioned RT was buggy, could you please let me know if you experienced any of the issues above? The developer can’t seem to be bothered, which is even more aggravating to me than the technical problems themselves, tbh. 

 

Thanks in advance

Share this post


Link to post
Share on other sites

Came here looking to answers about fill-in snippets. I tried various approach and Alfred is not suited for form based fill-in snippets. Typinator works best for this. 

 

I was for a moment thinking of decreasing the number of apps that I use and sticking with Alfred and Keyboard Maestro but it looks like I can't drop Typinator.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...