A BBEdit Codeless Language Module for Tinderbox Action Code

If you’ve downloaded the PopClip extension please download it again.

I created a small demo to be used with your great extension to my favourite text editor. With this setup it is easy to maintain the code snippets for TBX as external text files and reuse them in several TBX projects. All you need is a WatchFolder to import those files.
There is one note called “gPreferences” and there for each and every note I store two values in a dict: the attribute ($Edict, $OnAdd…) the code should be copied into and the name of the note where this attribute is located. That’s all.

“TestTarget01” and “TestTarget02” are the notes where the action code should run. “WatchMe” is the folder with the external content and the action code snippets.

The $Edict of the “WatchMe” note contains:

$MyList=collect(children,$Name);
$MyList.each(x){
  var theName =$ExternalCode("/gPreferences")[x];
  var theTarget =$ExternalTarget("/gPreferences")[x];
  $Edict(x) = "$" + theTarget + '(\"' + theName + '\")=$Text' + ";";
};

Again - thanks a lot for your CLM module.

ExternalCode.zip (33.0 KB)

4 Likes

Updated the CLM for Tinderbox 9.1. Please download it again.

3 Likes

Updated the CLM for Tinderbox 9.2.

Tinderbox.plist.zip (4.8 KB)

5 Likes

Updated the CLM for Tinderbox 9.3.

Tinderbox.plist.zip (4.8 KB)

1 Like

Yay! Thanks. As Tinderbox uses the ‘tbx’ extension unopposed, it might be useful to add extension detection and suggested new file save extension (for files with this language type set) for ‘tbx’.

I believe the extra syntax is this (per Barebones’ CLM notes):

<key>BBLMSuffixMap</key>
<array>
	<dict>
		<key>BBLMLanguageSuffix</key>
		string>.tbx</string>
	</dict>
</array>
<key>BBLMPreferredFilenameExtension</key>
<string>tbx</string>

Though I’m not 100% sure where in the plist it goes! Note, the use of a prefix period in one key’s value and not the other is as per the BBEdit docs. Tried adding at the end (inside outermost <dict> element) … and it works. :slight_smile:

Here is where i put the extra:

So, here is the amended version (unzips to ‘Tinderbox.plist’ ready for use): Ed- Tinderbox.plist.zip (4.9 KB)

What does it alter? If the amended CLM is used:

  • Opening files with a ‘tbx’ extension will automatically select the Tinderbox ‘language’ for code hinting. Of course, as presently, the current selection can be altered from the language pop-up in the left end of the document status bar. Not tested, but per docs, the ‘tbx’ match is case-insensitive
  • Saving a new file for the first time, if the language selected is ‘Tinderbox’, BBEdit’s default filename selection will include a ‘.tbx’ extension.

Above addition is minor, a their remains a big thank you for doing all the real heavy lift of making the file. Some years back, I tried a CLM for Tinderbox … and it ended badly :frowning:

Nice! I’ll try that later. The CLM was of course only possible with your incredibly useful aTbRef, thanks again and again :slight_smile:

I’ve spent the last hours searching for a way to add designators to the CLM, however some of them conflict with operators, e.g. Date.day (operator) vs. day (designator). In general it should be possible to distinguish between both by using regex (the regexes work in TextSoap and BBEdit), however I didn’t find a way to make it work in the CLM. I’ll probably reach out to BBEdit support as it would be nice to also have designators highlighted.

As well as support, there is a Google.groups forum at https://groups.google.com/g/bbedit which has helped me occasionally in the past (esp. when first learning about grep and regex.

I agree that having designators would be cool. I think the CLM colouring is essentially using string match so ‘today’ in $Text would likely be marked. As the point of the CLM is colour code such accidental colouring is not really problematic IMO.

IF going down that path, I’m not sure I’ve an exhaustive list of all the time/date strings accepted (if you include those) but i think they are case-insensitive and allow for singular and plural, i.e. any of day days Day Days etc. for a day scope and so on. That said there has been discussion as to whether these are designators or keywords.

As regards scope designators (item or group scope), I believe those are correct in aTbRef are the two linking-only designators source and destination.

Hood up on aTbRef as I struggle to get a better pan-document method for describing operator arguments, their purpose and their syntax. In some cases a description of just one of the two facets is insufficient data to guide the new/occasional user. Ideally I’d where possible link through to (or ^include()^) a single definition, e.g. of how scope is defined, or the how a string literal value is entered, etc.

Updated the CLM for Tinderbox 9.5.

Tinderbox.plist.zip (4.8 KB)

It now automatically chooses the Tinderbox language for *.tbx files. Nice idea @mwra!

3 Likes

@Pete thanks. Re-upping your install advidce (from the start of the thread, but d/l link for recent version) for today’s readers:

Installing the Codeless Language Module

  • Select BBEdit menu BBEdit > Folders > Language Modules
  • Download Tinderbox.plist.zip (4.8 KB)
  • Unzip and move the CLM
  • Restart BBEdit

The auto code type selection for TBX files works a treat. Thanks for sharing as it should help many of us.

3 Likes

@Pete, this is a super resource but I noticed two things. I don’t think they are errors but might point to some possible optimisations that perhaps a BBEdit forum could help with.

Once installed, the plist is now auto-applied to TBX files opening in BBEDit. However—and this is a subjective judgement—the file takes longer to open than with the otherwise auto-detected/set XML styling. It may be that as the XML system is built-in it may be optimised for speed.

Secondly, compared to XML styling, the tags in the TBX’s XML can’t be collapsed. IOW, you can’t collapse the lines from <links> to </links> into a single line using a disclosure triangle (like that in a Tinderbox outline. When present in BBEdit the triangle are shown outside the edit space along the left vertical edge and to the right of line numbers (if the latter are turned on).

As said the BBEdit forum (on Google) might have an answer for these.

Ah, yes. The CLM uses a regex (that was written for Tinderbox Action Code, not XML files) to fold text that’s inside brackets. The regex won’t work with XML, i.e. it’s not possible to fold XML with it. Nevertheless the regex is also applied if one opens a tbx (XML) file which is probably the reason why it’s slow.

I guess there’s nothing that can be done about it.

I meant to note that poking around in the plist, I noticed a URL points to the now old ‘atbref9’ baseline and not the new ‘atbref95’ baseline. I don’t think it matters greatly but note it in case.

1 Like

Fixed here. Thanks!

2 Likes

Updated the CLM for Tinderbox 9.5.2

Tinderbox.plist.zip (4.9 KB)

5 Likes

Updated the CLM for Tinderbox 9.7.0

Tinderbox.plist.zip (4.8 KB)

6 Likes

Updated the CLM for Tinderbox 9.7.3

Tinderbox.plist.zip (4.7 KB)

5 Likes

A genuine thanks :pray: for this effort on the community’s behalf.

1 Like

Thank you for aTbRef & Mark Bernstein for Tinderbox!

1 Like

What a great trifecta – Tinderbox-BBEdit-aTbRef! Thanks @Pete

1 Like