According to the user manual …
Node paths allow you to focus your document in sophisticated ways. For example I could use a node path to focus my document so that it only shows todo items that have not been marked as “@done”.
I have figured out how to show only the items marked as “@done” by either clicking on the tag or using the “Focus Tag” command. However, the user manual seems to indicate you can do the exact opposite, stating that you can “show todo items that have not been marked as @done.” How is this opposite effect achieved? Is there a command or menu option for hiding certain tags, in this case the @done tag?
Thanks for your help,
Markus
There are various options
With Jamie Kowalski’s filter plugin you can apply the whole range of filters enabled by the nodePaths described in FoldingText > Help > Node paths guide
Alternatively you could assign a keystroke to a script or plugin along these lines:
(In Applescript):
property pAllNodes : "///*"
property pNotDone : "//(not @done)"
property pstrJS : "
function (ed, opt) {
var strPath=
// is the vanilla path showing ?
ed.nodePath().toString() === opt.plain ?
opt.focused : // then focus
opt.plain; // else restore
ed.setNodePath(strPath);
return strPath;
}
"
on run
tell application "FoldingText"
set lstDocs to documents
if lstDocs ≠ {} then
tell item 1 of lstDocs
set varResult to (evaluate script pstrJS with options {|plain|:pAllNodes, focused:pNotDone})
end tell
end if
return varResult
end tell
end run
If you are using OS X 10.10 Yosemite, you can also write the script in JavaScript for Automation (JXA):
function run() {
var strPlain = '///*',
strFocused = '//(not @done)';
function toggle(ed, opt) {
var strPath =
// is the vanilla path showing ?
ed.nodePath().toString() === opt.plain ?
opt.focused : // then focus
opt.plain; // else restore
ed.setNodePath(strPath);
return strPath;
}
var docsFT = Application("FoldingText").documents(),
varResult = docsFT.length && docsFT[0].evaluate({
script: toggle.toString(),
withOptions: {
plain: strPlain,
focused: strFocused
}
});
return varResult;
}
And, FWIW, there’s a Toggle Hide Done plugin in this repository:
https://github.com/RobTrew/txtquery-tools/tree/master/toggle%20hide%20done%20items.ftplugin
Download zip
(That plugin, incidentally goes a little beyond a simple toggle between all and nothing, and allows for adding/substracting @done items from an existing filter of some other kind.
Analogous to a script like:
function run() {
var strTag = '@done';
function toggle(ed, opt) {
var strAll = '///*',
strTag = opt.tag,
strNot = '//not ' + strTag,
strExcept = ' except //' + strTag,
strPath = ed.nodePath().toString().trim(),
strNewPath=strAll;
// (IN SIMPLE CASES: just toggle back and forth)
if (strPath === strAll) strNewPath = strNot;
else if (strPath === strNot) strNewPath = strAll;
// IF SOME OTHER FILTER IS IN PLACE: add or drop `except //@tag`
else if (strPath.indexOf(strExcept) !== -1)
strNewPath = strPath.replace(strExcept, '');
else strNewPath = strPath + strExcept;
ed.setNodePath(strNewPath);
return strPath;
}
var docsFT = Application("FoldingText").documents(),
varResult = docsFT.length && docsFT[0].evaluate({
script: toggle.toString(),
withOptions: {
tag: strTag
}
});
return varResult;
}