What modifier to focus on branch?


#1

In FoldingText, Cmd-click a tag will focus on the whole branch rather than the sole tagged line.
Is there any way to do this in TP3 as well ?


#2

I’m trying to use the term “focus” for something else now… when you “focus” on an item it will:

  1. Hoist that items parent
  2. Hide all of that items siblings.
  3. Enable showing of all the items descendants (might not all show if some items are folded)

Right now when you select a project in the sidebar it is “focused”.

Instead I would reword your question as:

What modifier to filter on a branch?

And unfortunately I don’t have a direct route for you at the moment, but there are a few indirect routes. First unlike in FoldingText the active search is easily editable and you have have saved searches. So for example if you want FoldingTexts “Command-Click” behavior on @today tags in TaskPaper you can:

  1. Click @today tag. And then add //* to the search field so that you have @today//*.
  2. Alternatively you can create a saved search for your common tags that includes the //*.
  3. For a more dynamic solution you could create a script to filter on a tag’s branch. I’ve included a start at the end of this email.
  4. Also, unlike earlier versions of TaskPaper 3 preview, the latest version will allow you to expand any search result to see it’s children… previously the children were always hidden if they didn’t match the search no matter the expand/collapse state.

I’m not sure if this sort of option should be built into TaskPaper or not? I think for now I would rather a script do this.

// This script uses two bits of undocumented API. `bodyHighlightedAttributedString`
// and then the `tag` attributed name in that string. I think for this case they are OK to use
// though they might change in the future.
function TaskPaperContextScript(editor, options) {
  var selection = editor.selection;
  var item = selection.startItem;
  var itemHighlights = item.bodyHighlightedAttributedString;
  var tag = itemHighlights.getAttributeAtIndex('tag', selection.startOffset)
  if (tag) {
    editor.itemPathFilter = "@" + tag.substr(5) + "//*"
  }
}

Application("TaskPaper").documents[0].evaluate({
  script: TaskPaperContextScript.toString()
})

#3

Coming from FoldingText, I would suggest that yes, it should be.

Meanwhile, as @today//* will hide any items that doesn’t have descendant(s), I’ve achieved FT2 behavior using @today/descendant-or-self::*
Is this the right syntax ?

Thanks.


#4

Sorry lost track of this one.

Yes that’s correct syntax. Though there’s a shortcut for descendant-or-self to make it easier. Instead you can do @today///* for the same behavior.