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

@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?

thanks! didn’t realize it was just me - i should have tested on tw.com etc.
i’m using 5.3
image
looks like an issue with codemirror integration perhaps? i am using that plugin but it works fine with my other (single filter run) triggers, including the default [[ tiddler title autocomplete.

1 Like

Oh right, that’s that issue. It’s related to using the latest TW version I believe. I’ll take a look at this this week!

1 Like

@Maurycy I have encountered a strange interaction between AC and CodeMirror that leads to RSOD. I’m not sure it could be even described as a bug, since the required circumstances are quite weird, but maybe it is something worth knowing.

Steps to reproduce:

  1. Have Auto Complete (tested on latest 1.0.17) and CodeMirror (same version as TW) plugins installed.
  2. Add ctrl-space shortcut for sidebar-search (same as AC manual trigger).
  3. Put cursor after any AC trigger sequence in the CodeMirror field and press ctrl-space.
  4. The cursor jumps to search field and the AC popup shows up, so both shortcuts are in fact working, but an RSOD also shows up. Either with “Script error” (on TW/CM 5.2.7) or “Uncaught TypeError: Cannot read properties of null (reading ‘selectionStart’)” (on TW/CM 5.2.2 on your showcase page). I have caught no RSOD with other actions other than sidebar-search assigned to the same shortcut.

I realize these are weird conditions, I see no reason to have those two actions assigned to the same shortcut (I did it accidentally, as I simply forgot ctrl-space is already in use by AC). It can just as well be a problem with CM, since it doesn’t happen on non-CM fields even with CM installed.

Of course feel free to ignore it, if it is irrelevant.

@vilc I can’t take a good look right now but I’ll tackle it the same time I tackle the issue reported by @Scribs, thanks for reporting!

2 Likes

@Scribs and @vilc using code mirror with Autocomplete, avoid clashing with its bracket closure, I settled on triggers using the backtick which is not usually used this way so I could easily access both double and single patterns, perhaps try these to see if you get the same problem with codemirror

  • Consider code mirrors own completion / brackets etc in you selection of triggers, you can turn that off if your auto complete handles them.
  • On my keyboard backtick is unshifted top right and easy to use.
<` html tags
<<` macros/variable
{` tiddler transclusion
{!` field transclusion
[` etc...

1 Like

I installed a new alias plugin to use alternative name for a tiddler (i.e. Using Matt Lauber's Aliases plugin and displaying aliases as part of the current tiddler).

Could we search/filter by title and field (e.g. aliases) for auto-complete?

you should be able to search title and aliases field with the following filter:
[search:title,aliases<query>]
the search operator takes a list of fields in its suffix after the :, if you want to add other fields (like text) you can just add them with commas like above.
hope this helps

2 Likes

Thanks for your suggestions. nice tips

is it possible to evaluate and insert today’s date? [<now YYYY0MM0DD>] i couldn’t figure out a working solution just now, maybe i’m missing something obvious?

For me it worked

Suggestion Filter: [all[tiddlers]!sort[modified]limit[1]get[modified]format:date[0DD-0MM-YY 0hh:0mm]]

Display Filter:
[<currentTiddler>]

Template:
" d:$option$ "

3 Likes

A slight modification to @vyug18’s idea:

Suggestion filter: [<editedTiddler>get[modified]format:date[YYYY0MM0DD]] – should be slightly more performant, if you only need date, not time. I takes the modified date time of the current draft, so unless you start editing before midnight and insert timestamp after, it will be correct I guess.

Here is a complete trigger tiddler, ready to use, with trigger ddd:
$__EvidentlyCube_Trigger_CurrentDate.json (397 Bytes)

Edit: the modified field of the <editedTiddler> seems to be updated all the time on every edit to the draft, not just upon creating the draft. So this solution works also if one needs time in their timestamp.

1 Like

For this, I would absolutely go with Dynamic Rubber Stam by @Mark_S. I believe for this use case rubber stamp is more suitable and AutoComplete use case is different.

1 Like

thank you all very much @vyug18 @vilc @Mohammad ! i went with @vyug18 's solution as it was most appropriate for my needs on mobile; i tried to make it a wiki article but could not find a way to move it to a more appropriate place (tips & tricks?) thanks again, it’s really helped my workflow!

2 Likes

Life has its way of being annoying and taking you away from the important things.

Version 1.0.18 is out:

  • Fixed RSOD in TW 5.3.0+ caused by new API not being supported
  • Fixed RSOD when earlier keyup causes the focus to be changed – can be triggered by setting sidebar-search shortcut to the same key as manually triggering auto complete.

@Scribs The first part fixes the issue you reported here – this was caused by internal API changes introduced in TW 5.3.0

@vilc The second part fixes the issue you reported here – this was caused by the Sidebar Search shortcut having higher priority, which would cause focus to be lost, which would reset some variables (but not all) which was the source of the issue. It just gracefully cleans itself, I don’t believe there is a way for me to prevent the Sidebar shortcut (nor I am confident I’d like to do it anyway). Don’t share your shortcuts! :smiley:

4 Likes

@Maurycy I have found an inconsistency. I’m not sure it’s a bug, since I don’t know if this feature is supposed to be supported. And there’s an easy alternative in my use case anyway.

I need to use the regexp operator with a regular expression containing the character class/ range [a-z] in its parameter. In this case the the parameter cannot be literal regexp[[a-z]].
I tried the solution indicated in TW docs, that is to use a variable. I defined a global macro (tagged with both $:/tags/Macro and $:/tags/Global just in case) with the regex.
Using regexp<myMacro> (just a part of the filter ofc) yields this strange result:

  • “Test the filter” table in the trigger config shows proper results (in my case all titles starting with lowercase, by using regex ^[a-z])
  • Using the filter “in the wild”, it looks like the macro simply doesn’t work/ evaulates to nothing, or as if regexp[] was used.

I ended up using a data tiddler regexp{dataTiddler##property} and it works well everywhere. Same with field transclusion regexp{tiddlerWithFields!!field}.

Just wanted to let know. It’s not actually a problem for me, since I found the alternatives.

Edit: I’m using TW v5.3.1 and AC v1.0.18

1 Like

Whoops. That’s both a bug and expected behavior. The completion API runs with a faux base widget so it has no access to globally defined macros and variables, done mostly for simplicity of the codebase than for any other particular reason.

This should be fixed at some point for sure and I’ll take a note of this problem but no promises when this gets fixed. Glad you’ve got a good workaround!

I don’t know how I went this long without knowing this plugin existed. I needed this so bad I was considering making something like this myself.

As a community, TiddlyWiki really needs to work harder at improving plugin visibility.

4 Likes