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?
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.
Сreate a tiddler with tag $:/tags/StartupAction and text <$action-setfield $tiddler="$:/temp/AutoComplete/completion-data" throttle.refresh=""/>
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!
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!
Thanks for the update! As far as I have tested, the editedTiddler
variable works as expected.
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.
@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
orCtrl+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
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.
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!
@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:
- Have Auto Complete (tested on latest 1.0.17) and CodeMirror (same version as TW) plugins installed.
- Add
ctrl-space
shortcut for sidebar-search (same as AC manual trigger). - Put cursor after any AC trigger sequence in the CodeMirror field and press
ctrl-space
. - 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!
@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...
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