Tinderbox Forum

Incoming Links access through Applescript?

Piqued by the recent Roam discussions, I spent all of ten minutes exploring Roam. I liked what I saw, but felt I could easily replicate the nice bits in TB (specifically, easy links to new documents — which ziplinks already provides, and more — and navigating to these documents). Linking to subdocuments is nice, but a frill, I think.

The Note Pane with ziplinks is fantastic. I dislike the mouse and clicking (ergo reasons/history of wrist issues), so I plan to set up some automation using Alfred. For the current note, I know how to get the outgoing links if I want to offer navigating to them.

Can I get the incoming links? Didn’t see anything in Applescript dictionary answering that.

What am I going to do with all the links? Frankly, I don’t yet know. What I end up doing will depend on what is possible, which depends on what information the document is willing to divulge. One thing I will definitely do is a keyboard shortcut that shows the outgoing links in Alfred, so that clicking ⌘1 or ⌘2 or such will navigate there, as well as offer prototype based actions (highly personalized: when the prototype is book, I may want to suggest the alfred action of adding a linked container note where I could take notes from the book; when the prototype is theory, perhaps add the ability to add a note specifying weaknesses, evidence, proponents, and so forth). Ambitious, perhaps, but doable.

To cut to the chase, can I get the incoming links for a note through Applescript?

Thanks!
Abhijit

Investigating (with AppleScript Debugger), there is a links class:

The ‘path’ property had me confused until I realised it is the link type. The values due map - a link with no link type is (correctly) path value of “*untitled”.

tell application "Tinderbox 8"
	tell its window "Link Test.tbx"
		set x to destination of link 1 of note "Test" of document 1
		display dialog x
	end tell
end tell

That compiles but errors when run (tried in ASD and the Mac Script Editor). I get “Tinderbox 8 got an error: The specified object is a property, not an element.”, seemingly because it can’t resolve some properties like ‘nextSibling’. Odd, as according to the app dictionary, these properties shouldn’t apply to a link object.

I’d suggest dropping an email to Support (info@eastgate.com). But, in principle, it appears you you should be able to access and traverse links, via their source/destination info.

I am indeed able to go forward: from a note, I got the notes it connects to. But can I get notes that connect to the current note?

In the links shown below the note pane , both incoming and outgoing are displayed. AppleScript seemed to only offer access to the latter, unless I am making some mistake.

1 Like

My apologies for misunderstanding. AFAIK, Tinderbox doesn’t expose incoming links to any sort of automation. I suspect it could, given this is possible in the UI e.g. the text pane’s Links panel.

It does seem a feature request you could make (best emailed to Support with your use case) - as we’re only users here.

I believe I have found a solution to this, using the immense flexibility of evaluate. The following produces the IDs of the notes pointing to theNote (and we can get paths or names instead if we wish). The syntax is funny but very powerful.

	tell application "Tinderbox 8"
		tell front document
			set notePath to "/my/Foo/Foo Child"
			set theNote to (find note in it with path notePath)
			evaluate theNote with "links.inbound..$ID"
		end tell
	end tell
2 Likes