Tcl:: Language Module

TextWrangler includes basic support for Tcl syntax highlighting and procedure recognition. Procedures are listed in a popup menu that makes it easy to navigate around large files. Unfortunately, this mechanism does not recognize procedures defined in a namespace with the concise namespace::procedure syntax. The intervening “::” characters are not among those TextWrangler normally recognizes as valid identifier characters.

For example, “Bar” appears in the function menu when a procedure is defined like this:

namespace eval Foo {
    proc Bar {} {
        puts "Hello, World!"
    }
}

I prefer this syntax:

proc Foo::Bar {} {
    puts "Hello, World!"
}

but procedures defined this way don’t appear in the function menu:

TextWrangler's Default Tcl Procedure Recognition

Rather than forfeit the convenience of the function popup or conform to a more cumbersome convention, I created a codeless language module that essentially duplicates TextWrangler’s built-in Tcl support. The only distinction is that I’ve added the colon to the “Identifier and Keyword Characters” string. As a result, TextWrangler recognizes strings containing colons as valid procedure names:

Namespace Compatible Tcl Procedure Recognition

Unfortunately, this approach appears to prevent recognition of the nested syntax. Ideally I would like to support both styles.

Download

I believe this module should be compatible with BBEdit as well as TextWrangler.

Tcl:: Codeless Language Module 1k .zip

Installation

Put Tcl.plist in ~/Library/Application Support/TextWrangler/Language Modules/ and restart TextWrangler. The module identifies itself as “Tcl::” to differentiate it from TextWrangler’s internal “Tcl” mode, which remains available. It may be necessary to tweak your language preferences to use this module by default, as shown here.

Please share any problems you encounter with this module, particularly those related to the colon’s promoted status.

Posted on Thursday, September 6th, 2007. Tags: .