Menu of tags for toggling focus and hide

An OS X Yosemite Javascript script which:

  1. Displays a menu of tags in the document,
  2. shows the active node path and the visibility counts for each type of tag,
  3. and allows selection of multiple tag types for hiding or focusing.

https://github.com/RobTrew/txtquery-tools/blob/master/filtering%20in%20the%20editor/tagsToggleHideFocus-js.applescript

Ver 0.5 preserves multiple selections in the menu:

faster toggling focus ⇄ hide

https://github.com/RobTrew/txtquery-tools/blob/master/filtering%20in%20the%20editor/tagsToggleHideFocus-js.applescript

Launching a compiled Yosemite JavaScript for Applications .scpt from KeyBoard Maestro:

osascript -l JavaScript *path*

Hi, I just added this to the FoldingText Alfred workflow and noticed that if the tag is on a block, then the whole block is not affected, just the one line. Therefore,

test.todo @test

 - item 1

becomes:


- item 1

When you hide the test tag. The … is the hidden tag. Would it not be better to hide that hold block?

I am figuring that this is more aimed at todo lists where each item is tagged and not whole blocks. Since I use tags for adding new items, I tag blocks to add new sub-items from Alfred.

Could you explain a little more what you mean by a ‘block’ ?

Is it a FoldingText heading and its descendants ?

In the FT node tree, the immediate scope of a tag is a node, representing a line. This script is simply changing node paths. If you need a version which toggles the visibility of nodes descending from the tagged nodes, you could edit the lines in the script which are setting the node paths.

(using a descendant-or-self axis)

Yea, I am referring to a block as a node and it’s descendents. It caught me off guard that it did not fold the decedents. That make since for tags in a todo list. I just use tags everywhere!

Okay. I think I will change mine for folding the descendents as well.

I’ve added options for including descendants of tagged nodes in hiding and/or focusing to ver 0.6

https://github.com/RobTrew/txtquery-tools/blob/master/filtering%20in%20the%20editor/tagsToggleHideFocus-js.applescript

Defaults are:

hidedescendants:true,
focusdescendants:false
	var dctOpt = {
		title: "View/hide tagged nodes in FT",
		ver: "0.6",
		description:"Menu for hiding or focusing on particular tags.\
		(and optionally any descendants - see options: 6 lines below this)\
		showing active node paths with counts of hidden\
		and visible tags of each kind.",
		author: "RobTrew",
		license: "MIT",
		site: "https://github.com/RobTrew/txtquery-tools",
		hidedescendants:true,
		focusdescendants:false
	};

Thanks. That was what I was working out. I think this will be great.

I’ve added options to the menu, so that ancestral and descendant elements can be toggled in and out of the filtered view with a dbl-click.

https://github.com/RobTrew/txtquery-tools/blob/master/filtering%20in%20the%20editor/tagsToggleHideFocus-js.applescript

Thanks. This is even better. And a great example of using JavaScript for Automation. There is very little documentation on that version of JavaScript. But, I like it so much more than AppleScript!!!