Thank you so much for this quick and brilliant reply!
I tried this out on a separate copy of my tw and it almost works perfectly. The one problem is that I’d like there to be some way to use relink to change all links to now link to the newly-named tiddlers. Is that possible, do you think?
@noa I think avoiding Camel case in titles is simple, and Eric is helping you remove them, but from experience this should not be an issue, as you can see it is not an issue in the various default core lists that tiddlywiki uses such as recent, open etc…
Can you illustrate where this is causing a problem?
More often that not it can be addressed by converting a title to text, or wrapping [[the whole title as a tiddler title]].
<$text text={{!!title}}/>
So I am arguing the “Null Case”, don’t change them, deal with them. I/we are happy to help you resolve this and cope with camelCase in titles as well as helping improve your coding practice.
@Flibbles
If you use the above code without limit[50] in $list widget, with relink installed on https://tiddlywiki.com, TW freezes! Is there any any solution for this?
May be @jeremyruston also can give some advices here. If user can see a message like: operation in progress… wait
What do you expect? If you change a single tiddler title, the relink plugin has to go through every single tiddler and apply it’s magic. Not only the title. It has to check the whole text, all fields, every macro definition and possibly some other stuff …
So eg: 2000 tiddlers to check times 50 tiddlers to rename. You have to go 10000 times through the whole wiki. Or 4 000 000 times, if you want to do it all in 1 run. … What do you expect?
TW doesn’t freeze for me. It just take a minute. It’s having to sift through every tiddler many times, and as much as it tries to cache, each relink causes every touched tiddler to be re-evaluated. You’re performing an expensive operation there.
The problem is, that TW doesn’t know that upfront. Neither does the browser. … Most browsers will show a message after some seconds, that there is something going on with javascript and if you want to stop it.
Clicking the “Continue” button several times may be resolve the issue. …
Clicking “Stop” will definitely cause an undefined state and a reload has to be done.
I would put the onus on the one making bulk operators about creating a “Working… please wait” indication. The best way to do that would be to make a javascript macro which pushes each of these renames to the event stack, one-after-another so that it has time to clear between each tiddler. That would keep it from freezing while it’s working.
Thank you both @pmario and @Flibbles
I documented this in TW-Scripts and will push it to GitHub soon!
You are right, this is a very expensive operation! So, while you gave useful hints, I think it is fair to use ALSO the first solution e.g. use limit[50] and click the button several times.
This kind of problem who’s execution results in many iterations and thus time, is similar to Dynamic Programing where the programer can estimate the time and space required for a given algorithm process and finding ways to optimise it.
Perhaps a “poormans” version would be in such cases to put some analytics on a sample of cases eg 10 or 100, then given a count of cases estimate the time to do all “remaining” cases. A method to click to do next 10, next 100, All etc… and let the user make a decision according to the “time to complete”.
The real solution is to create a custom javascript macro:
// This tiddler can be transcluded into whatever tiddler has
// the "un-camel-case button", and it will show a growing
// percentage number of progress.
var stateTiddler = "$:/state/progress";
exports.run = function(stringListOfTiddlers) {
var i = 0,
list = $tw.utils.parseStringArray(stringListOfTiddlers);
function next() {
// Set the progress percentage
$tw.wiki.addTiddler({title: stateTiddler, text: i / list.length });
// Do the actual renaming of the next tiddler
$tw.wiki.renameTiddler(listOfTiddlers[i], /* New tiddler name */);
i++;
if (i < list.length) {
// More tiddlers to go. Push the next rename to the event queue.
$tw.utils.nextTick(next);
} else {
// No more tiddlers to rename. Delete progress tiddler
$tw.wiki.deleteTiddler(stateTiddler);
}
}
next();
};
This is completely untested, but if this operation is to be part of a plugin (say TW-Commander), then this is the way you’d keep TiddlyWiki from freezing up while it’s working, and it gives a nice progress percent indicator.
(This is completely untested. I didn’t even make sure I got the right function names.)
EDIT: Yeah, now that I think about it, you want this to be a custom action-widget, not a macro, but same idea.
@noa Sorry to revive this thread, but I’m interested in why you decided to move away from CamelCase titles? I’m asking because I have been considering the opposite move (spaces to CamelCase), and I’m wondering what the reasoning was behind abandoning CamelCase?
I’m curious about OP (noa’s) reasoning as well, but for anyone writing TiddlyWiki projects for eventual publication to a beyond-TW-insider public audience, all the CamelCase stuff is a terrible distracting departure from natural language.
(Also, if you work with names like McIntyre, having to remember to type such names with the tilde prefix — to avoid having them appear as links/missing links — is a drag.)
I never know what tiddlers I may want to copy over to a public-facing wiki, so it makes sense to set the CamelCaseToLink norm aside from the beginning.
I think my reasons are very similar to Springer’s. When I send pages from my wiki to friends, I want it to read naturally. Although even with just a private-facing wiki, I feel the same way. I like the aesthetic of a “normal”- looking page with links that don’t break up the natural flow of the language.
Now I’m curious to know for Sii and others who are switching to/sticking with CamelCase, what elements convinced you to do that?
With tiddlywiki you have so many possible options it is hard to imagine them all, take my word there is no problem here.
Keep in mind TiddlyWiki is by definition a Wiki, this is a core function of wikis, but yes you can avoid and or refactor as your heart desires.
The solution on this thread is a useful retrospective tool.
Some thoughts on this;
When authoring a tiddler or the whole wiki decide if you want to make use of camel case
Use plain English and no camel case and turn off Control Panel, Settings, Camel Case Wiki Links so your McIntyre will be left alone.
Use the editor toolbar [[*]] to wrap words or phrases to generate internal links and cross references
If you chose to use camel case but now want to change them
install the relink plugin and open each tiddler using camel case and rename them without camel case, all links to it will be updated (and Use Eric/Mohamad’s tool)
If you want to think ahead instead of using camel case and [[ ]] use a macro to generate links to other tiddlers, we can use the excise button to invoke a macro or create another Editor Toolbar button to wrap links in a custom macro with any features you want, like use the tiddlers caption.
We could even create an editor toolbar button that given selected words (Currently forming camel case) could be converted to sentence case and rename the tiddler linked to, needs a little regex.
Inspired by this thread I may very well build an editor Toolbar button in time, and I think it would be nice to build a tool that allows you to drag and drop or export any tiddler along with every internal link and their tiddlers.
Yes this has a lot to do with why I am considering the change. I am more interested in titles being recognisable than readable, if that makes sense. For me a title is just a label for an idea, rather than something that is descriptive in of itself.
Like many peopIe I use TiddlyWiki as a zettelkasten for collecting and engaging with idea-oriented notes. The goal is to treat each of these notes as individual units to be reused.
For me unique titles are a crucial part of this system. Naming an idea mimics chunking. By reducing an idea into a single label the idea can more readily be reused in different contexts without overloading your working memory. This is analogous to using functions in a programming language. Functions abstract away the details of a block of code into a single unit that you can reuse and layer together with other functions to form a complex system that your brain would not otherwise be able to make sense of.
Up until now I have used complete sentences as titles - inspired by Andy Matuschak’s notes. I have just tended to find that this makes it harder to think of ideas as individual units. I struggle to remember the names I have used, and often mix up ideas, or end up duplicating them. I think I often struggle to distinguish between the title and the content of the tiddler in my mind, probably because they are both just written in normal English.
I am considering CamelCase titles because the are more like individual words an thus better suited as labels or ‘chunks’. The main downside that I anticipate is that I feel it might encourage less atomic ideas. I still want each tiddler represent a specific claim, and I don’t want tiddlers to end up just being categories that list a bunch of broadly related ideas.
I agree, however, that this approach might not be well-suited for a public facing or shared wiki.