Stupid Autocomplete

This was a silly experiment as something I’m building is having compatibility problems with edit-comptext. I wondered how I could take a very simple approach with pure WikiText. In my tool, I have <$edit-text> areas for lines of notes. I couldn’t catch the [[ to prompt for things, but I thought I might be able to wait until a bad link is tried, and then intercept it. This is a hacky example of that. Not useful alone in it’s current state, but thought it was kind of interesting and possibly useful for a similar use case somebody else had.

\define myreplace() <$action-setfield $tiddler="$(currentTiddler)$" $value={{{ [[$(currentTiddler)$]get[text]search-replace:regexp[$(links)$],[$(matches)$]] }}}/>
\define edit-auto(tiddler)
<$edit-text tag="input" default="" tiddler="""$tiddler$""" size="80"/><br>
<$tiddler tiddler="$tiddler$">
<$list filter="[<currentTiddler>links[]]" variable="links">
<$list filter="[<links>!is[tiddler]]" variable="x">
Replace "<<links>>" with:
<$list filter="[search:title<links>limit[10]]" variable="matches">
<$button class="tc-btn-invisible tc-tiddlylink" actions=<<myreplace>>><$text text=<<matches>>/></$button> &nbsp;
</$list>
<br>
</$list>
</$list>
</$tiddler>
\end

* <<edit-auto "temp">>

stupid-autocomplete

2 Likes

Kudos!

Better name: “Good enough AutoComplete” :nerd_face:

Very clever! I like it much more than having dropdowns, which I really h… :wink: