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

The Sales Pitch

I am talking to you.

Yes, you, the person with so many tiddlers in your TW that you can’t remember all of their names. You who thinks using Create Wikilink Text or pressing Ctrl+L is against the nature.

What if I told you you can have Auto Complete for Tiddlers. For field names. For macros. For your dreams, secrets and desires?

Search no more, call Auto Complete for a quote NOW.

Documentation · Demo · Install: Auto Complete

And a bit more seriously

Auto Complete was inspired by Snowgoon88’s TW5-extendedit and was made to solve some bugs that plagued my usage of it.

Main features are:

  • Can define your own triggers using built-in editor
  • Auto complete anything you want, as long as you can write a filter that returns it
  • Customize how items are displayed in the autocomplete
  • Works in all text inputs and even Code Mirror

Plugin compatibility:

Documentation · Demo · Install: Auto Complete

Why should you switch?

Now the unpleasant part. Chances are you’ve been using TW5-extendedit and are happy with it so why should you care about switching? Unfortunately my experience with that plugin was that it was at least a little buggy:

  • Automatically opening completion was inconsistent if you typed fast – this shouldn’t be the case with Auto Complete.
  • Ditto for manually triggering.
  • Its JSON configuration is unwieldy – Auto Complete gives you a nice user interface to configure everything.

That being said it does not (as of yet) implement features like:

  • Case insensitivity
  • Minimum pattern length before completion opens

Screenshots

Autocomplete in action:
image

Options:

Customizing a trigger:

Documentation · Demo · Install: Auto Complete

Changelog:

  • 1.0.15:
    • Code Mirror integration: No longer throws an exception when triggering completion in non-codemirror input when codemirror editor is opened
    • Code Mirror integration: Completion opens at the correct position even when window is scrolled
    • Code Mirror integration: No longer throws an exception when selecting an option with mouse in non-codemirror input when codemirror editor is opened
  • 1.0.14:
    • Fixed a bug where navigating through auto completion would still trigger TW’s keyboard widgets eg. navigating auto completion in sidebar search would also change selected search result
    • The list of suggestion can now be scrolled down using the keyboard.
  • 1.0.13:
    • Added caption to triggers to improve how they are displayed in the settings
  • 1.0.12:
    • Using mouse for Auto Complete now works in tiddlers opened in a separate window
    • No longer crashes when using together with a Twitter plugin or any other plugin which delays the execution of the startup module
    • This plugin now takes preference over codemirror-autocomplete and will prevent the code mirror Auto Complete from opening at the same time as this
    • Various small fixes and tweaks to problems introduced from 1.0.9 to 1.0.11.
22 Likes

Super exciting! I’ve advocated for auto complete making it into core. I wonder if this codebase is in shape to be considered for core inclusion?

I will give it a try and report back!

Difficult to say. The way I’ve written it – not, as it is split into multiple files and uses monkeypatching to inject some code to talk to Edit Text widget and engines internals. So at the very least more changes to the core would be required, which makes sense when I’d be… adding a module to the core, now that I think about it.

But frankly I’d rather keep it as a plugin anyway – gives me full freedom in how and when I do things!

Yes I understand. From a user perspective and someone wanting to see better UX in core, the ultimate value is having this be broadly supported :wink:

Appreciate you sharing this!

How much would this plugin cost realistically if it was an Open collective project or feature request?

Well, after only playing with it about 10-15 minutes, I love it! The configurability is awesome and it seems to work great! I’ve used edit-comptext for years and will very likely switch over. I will defintiely run it through its paces this weekend.

Great work! Thanks!

The plugin took me 6 days. Let’s say I spent 4 hours of actual work each day that makes it 24 hours of work. Then it’s a matter of determining an hourly rate which is a tough one. I could go with the rate I use at my day job as a programmer, go with something you could expect a good programmed in US charge or an outsourced programmer from poorer countries around the world. So the actual price would be somewhere between $400 and $2500.

But depending on whom you pay the quality might differ (not necessarily more expensive = better). If I wasn’t personally invested and was approached with making a plugin like that I’d probably quote it at around $1000, maybe slightly below. But given that I am personally invested I am happy to do it for free for the price of praise and external validation :wink:.

Thank you! If you used any of the features from edit-comptext that you miss in this one tell me which and I’ll see what I can do.

5 Likes

It would be nice if we could get this compatible with Streams. The issue is that hitting Enter in the framed editor to insert an autocomplete selection also triggers the handling for the same keydown event in Streams, where all of this is wikitext based and there is no ability to avoid it. TW5-extendededit had the same issue and this is the fairly ugly patch that resolved it.

If I recall correctly the issue is that the framed engine propagates keydown events from the iframe to the parent document to allow widgets such as the keyboard widget to handle them. However, this propagation happens before the autocomplete keyboard handling.

Thank you. It works on Android with Tiddloid, editcomptext did not which is very useful for me.

With editcompext it is possible to insert the text field of a tiddler instead of title or non-text field value. Is this possible with this plugin or could it be accomplished?

1.0.4 is out:

  • Works with Streams plugin
  • A new option Trasnform Filter added to triggers which allows you to transform the selected suggestion before it is inserted (for example if you want to return a field value instead)

One way to accomplish this would be to return the text in Suggestions Filter (previously known as Filter) and then use Display Filter to reverse engineer the Tiddler’s title but it could’ve been a problem if multiple tiddlers had the same text content.

Or update to 1.0.4 and use Transform Filter

It is now. The issue was solved by attaching the keydown handler for Auto Complete’s “insert suggestion” to the document as a capture listener, I didn’t really bother digging deeper because solving it this way should fix it for almost any plugin out there.

2 Likes

Thank you. This will be useful for any scenario where there is a keyboard widget around the textarea that has handling for the Enter key.

I also noticed that if you open a tiddler in a new window and trigger an autocomplete, the popup appears in the original window.

From the tiddler toolbar, choose to open this tiddler in a new window: Evidently Cube TiddlyWiki5 Plugin Showcase — All the TW5 plugins developed by me!

Note that each widget has a reference to the document (widget.document).

Thanks for putting this into my head now D:. With how TW is setup I don’t think I am able to do anything about this – window.js doesn’t have any hooks that would allow injecting anything besides the tiddler itself, I can’t monkeypatch the event handler because it’s an anonymous function and…

Okay maybe I see a way, I guess that’s what I’ll do instead of preparing for the upcoming DnD session.

1.0.5 is out now:

  • When you open a Tiddler in an external window Auto Complete now appears in that window too.

And done!

@Maurycy
Am I seeing a bug here. I tried the plugin in the demo site.

When I typed [[ a pop up appears

Now when I select one of the suggestions, the autocompletion happens. But a pipe character gets added before the text like this [[|text]]

Not a bug, the demo site is configured for pretty links.

2 Likes

@Maurycy
This is very useful. I even created a trigger for transclusion - which work nicely.

You have written that autocompletion works for macros. What filter should be used for macros?

Like saqimtiaz said, that’s how it’s configured. I might need to change it if it’s confusing – or improve the docs to make it cleaner.

I can’t help but notice you don’t ask how to write autocompletion for dreams, secrets and desires :).

Unfortunately there is no easy way to automate it. I can see two options:

  1. Filter through all tiddlers with $:/tags/Macro, get text, extract all defines and use that as a basis.
  2. But likely a better option would be to create a Dictionary Tiddler with the list of macros you want to autocomplete and go with that.
2 Likes

I understood it when Saq gave the tip

:grinning:

Let me try it out. Thanks for the tip.

Wonderful job! This worth more than US$10,000 not US$2400. You solved an issue people wished for a long time.

I see it can be used for macro, syntax, … autocompletion! For a plugin like Shiraz which has too many macros, this tool is a huge help.

1 Like