Highlighting nodes that have aliases


(Christian) #1

I checked the forum and was not lucky for this one. So here comes my question.

I use a lot of aliases and I keep on removing nodes without knowing they have aliases. But then aliases are removed too. Why are nodes with aliases not highlighted?

A small icon or different color background would be enough to make one aware of the existing aliases.
How can I best implement that for example with an agent? I know there is $IsAlias but there does not seem any equivalent for a node that has aliases.

Thanks in advance!


(Paul Walters) #2

Tinderbox has several features that might lend themselves to giving notes “small icons or different backgrounds” to indicate whether this or that condition is true or false. And those conditions might matter to one user but not to another, and in fact might confuse the other user.

So, in my opinion, it is better for the end user to decide what they want to be notified about and using features, such as agents or stamps in conjunction with attributes such as $DisplayExpression, or $Badge or $Color, to tweak the interface the way that makes the most sense to you.

See, for example Querying for Agents in aTbRef, build an agent that finds the parents of aliases and assigns a $DisplayExpress to those parents.


(Mark Anderson) #3

$IsAlias works both ways:

true - the object is an alias
false- the object is not an alias, thus the original note of any alias will have this value.

There is no ‘does this note have any aliases?’ command, but it is possible to test if a note has aliases using find(). First, I would point out that automatically generated aliases inside agents and aliases created manually by us users cannot be differentiated**.

Unlike an agent query, a find() query returns all instances of a an in-scope match both originals and all their aliases. Thus if your scope is the whole document, if you test a note for note’s matching the current note’s name (assumption! no duplicate original note names), than we can filter the results. I tested this edict :

if(find($Name==$Name(that)&$IsAlias).count>0)
{$Color="bright red"}
else
{$Color=;}

Any note that has aliases is bright red or else it is/reverts to its default colour. I’ve used colour here but you can set whatever indicator you like such as some of the alternates already suggested in the previous reply.

** Actually, that is possible by extending the query:

if(find($Name==$Name(that)&$IsAlias&$AgentQuery(parent)=="").count>0)
{$Color="bright red"}
else
{$Color=;}

Whilst for both originals and aliases outside agents their parent has no $AgentQuery value, the $IsAlias term has already filtered original notes, so that the extra query now whittles away aliases that only exist within agents. Neat!

An edict is a good vehicle for this sort of thing as it runs infrequently yet can easily be refreshed one-off on demand. Note you can’t use an agent for this, both because find() isn’t intended for agent queries and because you’d be chasing you tail is you weeded aliases inside agents.

(Tested in v7.5.4 on macOS 10.13.6)


(Christian) #4

Thanks a lot to both of you for the quick and comprehensive replies. :smile: The solution works great. I made it work with a badge. $Badge=“signal”.

I am not really familiar with editcs and wonder how I best run this now on all notes?
If I select a parent note or container, then the child notes are not updated. Do I need to select all nodes and then run the edict? Then the edict would be written into all nodes. I am not sure if that makes sense.


(Mark Anderson) #5

Pro tip: use prototypes. You then set/edit the edict in the prototype and it is automatically inherited by notes using the prototype (assuming they didn’t already have local edict - see resetting attributes).