Auto Complete plugin 1.0.15 - Complete tiddlers, fields and your dreams

Yes, / is good one, but so is I believe my suggestion the back tick, if it follows something, because then if not it is just code.

  • We could also use \ to trigger a selection from the new options on 5.3.0
\define
\procedure
\parameters

In fact all pragmas,

I think this solution will work best with this after market in sets of curated auto complete triggers, perhaps organised so when not designing you disable the TiddlyWiki Script items.

To me there is real value in leveraging existing symbols such as [ { | < because it is in a way self documenting, and appears when you are doing something with the elements that us the character.

I can also see value in pulling the default parameters from widgets, pull content from inside ( ) and change : to =

Here is my opinionated perspective, for you to throw “bouquets or brickbats” at.

  • I am not yet good enough to write the complex regex if needed for these yet.

    • \+backtick, pragmas *
    • /+backtick escaped regex (not sure here?)
    • etc…

[[ link tiddlers (in wikitext [[tiddlername]] ) ← existing
{{ transclude all tiddlers (in wikitext {{tiddlername}} ) *
|| transclude here all tiddlers (in wikitext {{||tiddlername}} ) ← existing
!! transclude field (in wikitext {{!!fieldname}} ) *
<< replacing macro: variable or macroname ( in wikitext <<macros>> ) *

And the harder to document using a single backtick

[` link all tiddlers (in filters `[tiddlername]`) *
{` transclude all tiddlers  (in filters `{tiddlername}`) *
{!` transclude field (in filters `{!fieldname}`) *
<` all macros (in filters `<macroname>`) *
<`??? all variables and macros (in filters `<macroname>`)
maybe also ?
  <m` for macros not variables ???
  <v` for variables not macros ???
  <p` for parameters ???
etc...
  • Note: When I use a single backtick in the trigger it does not display correctly in the Registered triggers
    • Changing from <code> to (Trigger <$text text={{!!trigger}}/>) fixes it.
  • The above lend themself to definition in data tiddlers, perhaps with a toggle to enable / disable.
  • I am building these now and will package, but there will be a few challenges
  • Edited to reflect changes as I build them, * used for those created
  • My efforts so far autocomplete-triggers.json (5.0 KB)

The beauty being we can do what ever we want :nerd_face:

I successfully created this one, only to realise the possibility of having one autocomplete triggering a second one, ie chain to another, hitting space after the inserted pragma, triggered the pragma for \whitespace<space>

For example type the following

\`wh<enter>

which gives you

\whitespace

Now add a space

\whitespace<space>

And it triggers an autocomplete of trim | notrim

\whitespace trim

This makes me realise this could be a complete syntax and parameters tool, I wonder if it could be performant enough as it stands?

Love your work @Maurycy

One issue with [, (, { is if you have codemirror-autoclose-bracket installed, then these chars cause having extra brackets in finall autocomplete!

I see @Maurycy has listed this in his Raod Plan. By that time I dropped brackets from my autocomplete triggers.

I believe AutoComplete can save you a lot and helps newcomers to get onboard. So Autocomplete is an essential plugin!

I note that if codemirror provides the braces, then it is just a matter of changing what autocomplete inserts? for example with {{ don’t supply the closing braces because code mirror will do it.

  • Thus autocomplete can have a different template field to use when the code mirror plugin(s) are active, that is use that instead.
  • I just tested it with {{ and {<backtick> and it works.

Post script: Because there is no need to change the trigger there is nothing different between with or without codemirror, just the replacement template.

A post was merged into an existing topic: Community Curated AutoComplete Triggers

See also: Community Curated AutoComplete Triggers - Tips & Tricks - Talk TW (tiddlywiki.org)

1 Like

@Maurycy, would it be difficult to add refresh throttling to the dropdown?

Shouldn’t be too difficult, though I am curious – is the concern performance or usability? And is it an actual concern right now, or is it a hypothetical one?

1 Like

It’s a current performance concern: the [[ trigger generates some noticeable lag in my largest wiki. I think this is partly my own fault, as I’ve set it to search relink:references[] as well as existing tiddlers… but if it’s not too difficult to implement, I think a bit of throttling could make a big difference for me.

1 Like

Сreate a tiddler with tag $:/tags/StartupAction and text <$action-setfield $tiddler="$:/temp/AutoComplete/completion-data" throttle.refresh=""/>

3 Likes

Thanks! I’m always forgetting about startup actions.

Is it possible to use Auto Complete to complete single values of a list-containing field of the current tiddler?

My use case: I have a field (let’s say myfield) containing a space separated list of numeric IDs, e.g. 123 456 789 (these are not titles of existing tiddlers). I would like to easily refer to any of these IDs separately in the text of the tiddler. I would like to see suggestions with IDs only from the currently edited tiddler’s myfield, not from all tiddlers having myfield.

I have tried using a suggestion filter [all[current]get[myfield]split[ ]search<query>], and alternatively [all[current]get[draft.of]..., but I can’t seem to get it working. I have also tried simpler filters that begin with the current tiddler, not necessarily referencing myfield, also without success.

Is it possible to reference the currently edited tiddler (or its draft), and by extension, its fields?

Going by memory – no. It might be a little tricky but doable to expose those as variables so you can reference those.

I am scheduling some time this weekend to get back to working on TW stuff, so unless I get blocked by something (or life gets in the way again) you can expect an update with some quality of life changes and the above by next week!

3 Likes

I have found the following workaround to function quite well, maybe it will help if anyone will be looking for a similar thing.

Suggestion filter: [all[tiddlers]!is[system]search:title<query>get[myfield]split[ ]unique[]] – type the title of currently edited tiddler and se all IDs stored in its myfield field.

Display filter: [all[tiddlers]!is[system]search:myfield<currentTiddler>first[1]] [[/]] [<currentTiddler>] +[join[]] – the title will be displayed in front of the ID, to make sure the ID comes from the tiddler that we actually want, e.g. “MyTiddler/123”.

Version 1.0.17 is out:

  • The two <p> tags that were wrapping around the auto complete window have been reduced to a single <p> tag.
  • Variable editedTiddler can now be used in Suggestion Filter and Display Filter

Is it possible to reference the currently edited tiddler (or its draft), and by extension, its fields?

The new variable editedTiddler covers that specific case now!

5 Likes

Thanks for the update! As far as I have tested, the editedTiddler variable works as expected.

1 Like

Is it possible to make a click on the field as a trigger for autocomplete? I wouldn’t ask, but the point is that there is a small problem in the official tag picker that is not in the in your plugin. As you type the tag, the focus is not automatically turned on on the first element, need additional press down.

1-2023-07-05_12.40.04

1 Like

@moosh If I understand correctly you’d like it to auto trigger only in the tag input? Not at the moment - there are some long term plans about adding auto trigger conditions. With those implemented it’d be possible to also add triggering on focus, but that’s far in the future I am afraid. Until then you’ll have to deal with the way things work right now.

I suppose another option would be to support dispatching a TW event that triggers a specific completion, but that’s also something slated for the future.

@Maurycy, is it possible to use multiple filter runs (with prefixes like :map etc) in the “suggestion filter” box? i was taking a shot at something suggested by @Mohammad above (making autocomplete for macros) and the filter i came up with had multiple runs:

[all[shadows+tiddlers]tag[$:/tags/Macro]] :map:flat[<currentTiddler>get[text]split[(]split[\end]trim[]removeprefix[\define]] +[search<query>]

i got a javascript RSOE when this triggered (by typing <<), though it did work correctly in the “Test the filter” section on the trigger tiddler.
thanks!

I just checked the filter on the plugin showcase, creating a new trigger, setting the trigger string to << and using the filter you given; it worked fine. I’ll need a bit more information:

  • Which TW version are you using?
  • Can you open browser’s developer tools (F12 or Ctrl+Shift+I), open the tab Console and there should be information about the error - can you send me a screenshot?