Korean Guy Posted November 10, 2018 Share Posted November 10, 2018 I love the snippets feature and uses like 100 times a day! One thing I wish Alfred could is, I could set up a certain group of snippets to be working on certain language input mode only for example I use ;br to make it best regards, I never type ;br on English, but I use it when I type different language. So it would be nice to make it disable this snippet to work when I'm using different language. Many thanks!!!! dfay and CJK 2 Link to comment Share on other sites More sharing options...
dfay Posted November 10, 2018 Share Posted November 10, 2018 This is a great idea and not one that’s supported by other text expansion software as far as I know. Link to comment Share on other sites More sharing options...
deanishe Posted November 10, 2018 Share Posted November 10, 2018 Could you provide an example that Westerners would understand, @Korean Guy? I don't really see the point myself. I deliberately leverage the key re-mapping when I switch input language to "localise" my snippets. For example, I have the English date (dd/MM/yyyy) mapped to zzdd and the German date (dd.MM.yyyy) mapped to yydd. That way, hitting the same physical keys will give me the English date when I'm using English input and the German date when I'm using German input (the Z and Y keys are swapped on English/German layouts). Importantly, I can still access the other snippet under a different keyword when I'm writing something that contains both languages (which I do fairly often). Link to comment Share on other sites More sharing options...
Korean Guy Posted November 10, 2018 Author Share Posted November 10, 2018 4 hours ago, dfay said: This is a great idea and not one that’s supported by other text expansion software as far as I know. Thank you @dfay ;) Link to comment Share on other sites More sharing options...
Korean Guy Posted November 10, 2018 Author Share Posted November 10, 2018 1 hour ago, deanishe said: Could you provide an example that Westerners would understand, @Korean Guy? I don't really see the point myself. I deliberately leverage the key re-mapping when I switch input language to "localise" my snippets. For example, I have the English date (dd/MM/yyyy) mapped to zzdd and the German date (dd.MM.yyyy) mapped to yydd. That way, hitting the same physical keys will give me the English date when I'm using English input and the German date when I'm using German input (the Z and Y keys are swapped on English/German layouts). Importantly, I can still access the other snippet under a different keyword when I'm writing something that contains both languages (which I do fairly often). Thanks for your feedback @deanishe Yes if it was like Simple zzdd or yydd only then maybe less likely you have overlapping snippets. But I use English Japanese Chinese Korean and while I register lots of lots of snippets of 4 languages, snippets would trigger accidentally while I am using different language. For exalmple my snippets are something like ili ijh jun etc, and these would never triggered accidentally while I type Asian languages but it would when I type English. It’s like you have to type zzdd or yydd on other strange languages. I know I can put .. or ;; before snippets but I use them so often so I try to make it short as much as possible. :) Link to comment Share on other sites More sharing options...
deanishe Posted November 10, 2018 Share Posted November 10, 2018 30 minutes ago, Korean Guy said: I use English Japanese Chinese Korean Right. Four languages is quite a lot. 26 minutes ago, Korean Guy said: It’s like you have to type zzdd or yydd on other strange languages. Sure. When it comes to system-wide snippet expansion, it's generally considered best practice to use snippet triggers that you would never, ever normally type. Link to comment Share on other sites More sharing options...
nikivi Posted November 10, 2018 Share Posted November 10, 2018 Another option that I personally use (don't have many text triggered expansions) is searching through expansions you need. I have bad memory for things that I don't use often so text expansions outside of ones like (:s or :d to expand my current Safari URL or embed URL into a markdown image) are going to be forgotten and not used. So I use Typinator's smart search which (in my experience) after few typed characters always knows the trigger I want to expand. This way I don't have to remember the triggers as I get visual feedback for what the triggers I have by typing few characters from the expanded result. Looks like this: Link to comment Share on other sites More sharing options...
Vero Posted November 12, 2018 Share Posted November 12, 2018 Thanks everyone for your insight into why you're suggesting this. I'll be upfront and say it's highly unlikely we'd implement something like this, as there's very little benefit. As @deanishe suggested, best practice is to use snippets that will never be triggered accidentally - regardless of your current keyboard language. I frequently switch between French and English, and have snippet collections for the various purposes. However, I always make sure my snippets are obscure enough to never be triggered accidentally. If you're not familiar with them, do take a look at the affixes; Setting a collection-wide prefix is a convenient way of creating new snippets without having to make sure you're manually being consistent about your prefixes: https://www.alfredapp.com/help/features/snippets/collections/ e.g. A few of my English collections use :: as prefix, while my French collection uses // as prefix. @nikivi You can use the Snippets viewer to do pretty much exactly what you've described. Pop up the Clipboard using its hotkey (or set a Snippet Viewer hotkey) and either navigate into a Snippet Collection, or simply start typing the title or keyword of a snippet. You'll see the full snippet on the right, and the keyword at the bottom to remind you of precisely what the snippet keyword is for next time. Cheers, Vero Link to comment Share on other sites More sharing options...
deanishe Posted November 12, 2018 Share Posted November 12, 2018 (edited) 10 hours ago, Vero said: uses // as prefix Definitely not a programmer (or one of those evil ones that never comments anything) Edited November 12, 2018 by deanishe Link to comment Share on other sites More sharing options...
CJK Posted November 12, 2018 Share Posted November 12, 2018 (edited) I have noticed that there's a Snippet Trigger, which I assume allows one to create a keyword shortcut that acts as a snippet, expanding to whatever result of the ensuing workflow yields. Is that anywhere close to how it works ? If so, an off-the-top-of-my-head idea and without much firsthand experience using Alfred snippets (I use Typinator), makes it seem to me that it might be possible to create snippets that share a common abbreviation/keyword, but—through a multi-pronged workflow that incorporates a tiny bit of scripting—could expand to produce something that depends entirely upon the currently selected keyboard input source. I'm not the best person to play around with this, as I'm monolingual. However, I have put together a few lines of key Javascript for Automation (JXA) code that would prove useful if anyone else wanted to see what they can do to make snippets more flexible or less likely to clash for multilingual persons: ObjC.import('AppKit'); inputContext = $.NSTextInputContext.currentInputContext; inputSources = ObjC.deepUnwrap(inputContext.keyboardInputSources); inputSource = ObjC.unwrap(inputContext.selectedKeyboardInputSource); //--> "com.apple.keylayout.British" localisedName = ObjC.unwrap( $.NSTextInputContext .localizedNameForInputSource(inputSource) ); //--> "British" I've printed example values for the last two variables, which are actual values returned on my system. The other value of possible interest is the variable inputSources, which produces a list of available input sources, mirroring what appears listed in the input menu if you have it accessible from the menu bar. Edited November 12, 2018 by CJK Link to comment Share on other sites More sharing options...
Vero Posted November 13, 2018 Share Posted November 13, 2018 13 hours ago, deanishe said: Definitely not a programmer (or one of those evil ones that never comments anything) Haha, keep in mind, // has to be followed directly by no space and the precise snippet, so // itself will never trigger anything. (And to be fair, my French collection only contains about 10 snippets, otherwise I might've picked something different). My daily-use Alfred support snippets collection doesn't need affixees, and the snippet keywords themselves are suitably obscure, yet extremely easy to type because they get constant use! Cheers, Vero Link to comment Share on other sites More sharing options...
deanishe Posted November 13, 2018 Share Posted November 13, 2018 20 hours ago, CJK said: I have noticed that there's a Snippet Trigger, which I assume allows one to create a keyword shortcut that acts as a snippet, expanding to whatever result of the ensuing workflow yields. Is that anywhere close to how it works ? Mostly. Snippet Triggers just launch workflows (after deleting the keyword). If you actually want to insert some text, which you probably do, you have to do that manually with the Copy & Paste Output. Their strength is launching List/Script Filters, so you can, say, just use one snippet to bring up a list of all the emojis and then choose the one you want instead of trying to remember a hundred different keywords. Using them to replicate regular snippets would be pretty cumbersome and not a whole lot of fun. Handy snippet, though. Is the “inputSources” line necessary? You don’t seem to use the variable again. Link to comment Share on other sites More sharing options...
nikivi Posted November 13, 2018 Share Posted November 13, 2018 24 minutes ago, deanishe said: instead of trying to remember a hundred different keywords Or Karabiner bindings. ? Link to comment Share on other sites More sharing options...
CJK Posted November 13, 2018 Share Posted November 13, 2018 1 hour ago, deanishe said: Is the “inputSources” line necessary? You don’t seem to use the variable again Nope. The script isn't presented as achieving any particular objective; it doesn't really do anything in its current state. It's just a triplet of related code snippets that demonstrate how to retrieve their respective bits of information, and I just failed to properly segregate or itemise them. 1 hour ago, deanishe said: Their strength is launching List/Script Filters, so you can, say, just use one snippet to bring up a list of all the emojis and then choose the one you want instead of trying to remember a hundred different keywords. So in this example, what's the snippet trigger doing that a keyword list filter isn't ? If a list filter contained all the emojis, then they would get shown by typing a single keyword, no ? Link to comment Share on other sites More sharing options...
dfay Posted November 13, 2018 Share Posted November 13, 2018 You'd need to call up Alfred then type the keyword. A snippet trigger aves a keystroke but more importantly it's less of an intrusion into ordinary typing flow (in my experience). CJK 1 Link to comment Share on other sites More sharing options...
deanishe Posted November 13, 2018 Share Posted November 13, 2018 2 hours ago, CJK said: The script isn't presented as achieving any particular objective; it doesn't really do anything in its current state. I understand perfectly what the code snippet does. I was just mildly confused by that line and wondered if it was perhaps a workaround for some strange bug. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now