Open Jermolene opened 6 years ago
That's an insteresting approach.
That's really cool :+1:
The core should directly support search and replace. Desirable features include:
- The ability for the user to review the changes as diffs, and individually accept r reject them
- The ability to restrict the search and replace operation to a specific field, or across all fields
In total agreement. Clearly for something so radical review is necessary before accepting the replace. But the scope covering potentially all fields on all Tiddlers would be very useful. At the moment I use external tools to do it. I would rather not because they lack the intelligent context that TW itself would give more appropriately.
This would be useful for tiddler renaming - though new users might think it's too techie, but in any case it's better than not having the option to update backlinks. However, in the case of renaming, the text and the fields must also be seen, so in this case the two views should be combined.
I could imagine the apply of replace as clicking on the hunk in diff (red / green text).
As I see, $:/core/modules/widgets/diff-text.js
is responsible for comparison (if someone wants to do it, do not have to look for it).
Do I understand right that this is intended for a "stand-alone tool" to post edit tids as opposed to a more integral function for string manipulations? Compare e.g with #3803 which requests a filter operator.
Hi @twMat this ticket describes a way to implement some of the UI of a user-facing search and replace feature. #3803 is about the underlying filter operator that performs the search and replace.
Do I understand right that this is intended for a "stand-alone tool" to post edit tids as opposed to a more integral function for string manipulations?
I'm not sure I understand what either of those means. Are you drawing a distinction between search and replace in edit mode for just the current tiddler?
I'm not sure I understand what either of those means. Are you drawing a distinction between search and replace in edit mode for just the current tiddler?
An example of what I mean with a "stand-alone tool" is the preview button; a special tool with a full UI. Contrast this to "integral function for string manipulations" which would typically be filter operators or perhaps widgets. My hesitation to say "filter operators" is because I am unsure how suitable the current implementation of filters are for manipulating strings in full texts because of how filters treats everything as lists. So maybe it Maybe this is a non-issue and I just fail to fully grasp it.
So my question is what your OP is to be used for. Is the intention only as a "stand alone tool" (like the preview tool) or some more general mechanism for hacking in wikitext, like a filter op or a widget?
If search and replace was available for a tiddler name within at a minimum, list fields including custom lists fields, which is already possible with a smart wikitext macro. Designers could then use a combination of renamable tags and and list fields to avoid the impact of a tiddler rename.
The above would go a long way.
All that remains then is the renamed tiddler appearing in the body or text of a tiddler.
I have long believed if we could iterate each line in the text field as if it were a field we could then apply a transformation like rename a detected tiddler title and then append that line to a new temporary tiddler. In the end replace the source tiddlers text field with that of the temporary tiddler.
This would open other features like a log tiddler which you progressively append lines to. Enable the ability to sort lines in a tiddler, or insert lines in a tiddler.
Of note, since such renames could be time consuming on renaming a tiddler the provision of a hack so people can write macros that are available at rename time would help, but providing a "Search" for the old tiddlers names in the wiki, and an optional checkable list of replacements would move this to an interactive process and not result in any surprises in processing time when they choose to have all mentions of the old tiddler updated.
The core should directly support search and replace. Desirable features include:
A significant part of the user interface functionality is implemented now that we have the diffing engine. It's also worth noting that a lot of the existing importing mechanism can actually be reused. For example:
$:/SearchAndReplace
tiddler, click the disclosure triangle to reveal the preview of the incoming tiddler, and switch the preview type to "Diff"The result is pretty much what we need for the second part of the search and replace UI: a way for the user to review the proposed changes and to accept or reject them individually. The text still talks of "importing", of course.