Make TiddlyWiki ignore the dirty state

…make the TW to ignore its dirty state…

The $:/config/SaverFilter shadow tiddler contains a filter that defines which tiddlers determine when the file is marked as “dirty” (i.e., needing saving). Here’s the default contents of that tiddler:

[all[]] -[prefix[$:/HistoryList]] -[prefix[$:/StoryList]]
-[status[pending]plugin-type[import]] -[[$:/isEncrypted]] -[[$:/UploadName]]
-[prefix[$:/state/]] -[prefix[$:/temp/]]

If you clear the contents of this tiddler (or add a leading “-” so [all[]] becomes -[all[]]) and then save the file, when you reload it, it will no longer require saving, regardless of any tiddlers you may change.

Note that $:/config/SaverFilter does not determine which tiddlers are actually saved when you press the “save changes” button. The filter that determines what gets saved is defined in $:/core/save/all, which has this contents:

\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]]
-[status[pending]plugin-type[import]] -[[$:/boot/boot.css]]
-[type[application/javascript]library[yes]] -[[$:/boot/boot.js]]
-[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$`
\end
{{$:/core/templates/tiddlywiki5.html}}

The saveTiddlerFilter() macro defines the list of tiddlers that will be saved. Take note of the last bit, where it says $(publishFilter)$. This allows you to easily modify the list of tiddlers without directly editing $:/core/save/all. Instead, define a separate macro named “publishFilter”, listing which tiddlers you do (or don’t) want saved.

For example, suppose you have a tiddler named “MyTempStuff” that you never want saved. To omit this tiddler from the save, just create a tiddler (e.g., “MyPublishFilter”), tagged with $:/tags/Macro, containing:

\define publishFilter() -[[MyTempStuff]]

From then on, “MyTempStuff” will not be saved with the rest of the file contents, and each time you save-and-reload, that tiddler will be automatically discarded.

Conversely, suppose you do want the $:/temp tiddlers to be saved. Then, you could write something like:

\define publishFilter() -[[MyTempStuff]] [prefix[$:/temp]]

which would reverse the effect of the default -[prefix[$:/temp] filter that exists in the $:/core/save/all shadow definition.

enjoy,
-e

5 Likes