TW5-codemirror-plus
TW5-codemirror-plus copied to clipboard
Customized Autocompletion
From Soren on the Google Groups
Can't speak for how Diego imagined it, but this kind of custom autocomplete is a really interesting idea. I would imagine that beginning an autocomplete run with a custom prefix would run an arbitrary filter and provide (much like the command palette in VSCode et al.) the results of the filter as choices. A variable completionText accessible within the filter would provide access to the current partial match (with the prefix removed).
It would be even awesomer if the current tiddler was also accessible within the custom filter, and if the text completed when you accept the completion can be something different than what's shown in the list (not sure if CodeMirror offers this kind of "snippet"-ish capability; see second example).
So e.g., config tiddlers could look like:
title: TagAutocompleter tags: $:/tags/CodeMirrorAutocomplete description: Allow tags to be autocompleted prefix: # filter: [tagging[]prefix<completionText>]
title: EmailAutocompleter tags: $:/tags/CodeMirrorAutocomplete description: Given part of a contact name, autocomplete the contact's email address prefix: @ filter: [tag[Contact]search:fullname<completionText>get[email]]
Then, say, to find specifically a tag called Test, even with 500 non-tag tiddlers beginning with T:
#T<C-space> ==> Test
And to complete an email address:
@Alice<C-space> ==> [email protected]