Home Download Buy Blog Forum Support

Get TCL Syntax without .tcl extension

Get TCL Syntax without .tcl extension

Postby pnelsonsr on Fri Oct 05, 2012 5:15 pm

I have a bunch of old tcl scripts that I have to support and they do not have a .tcl extension on them so sublime does not recognize them as tcl script. If I put a .tcl on them then sublime does recognize them as tcl. I can not figure out a way to tell sublime that they are tcl once I've already loaded them (and they display as just text) or how to tell sublime that any file that has

Code: Select all
#!/usr/bin/tclsh


at the beginning is a tcl script. Anyone know how I can do this? None of these tcl script files have any extension on them and it is a pain to add it every time I have to edit one.
pnelsonsr
 
Posts: 3
Joined: Fri Oct 05, 2012 5:07 pm

Re: Get TCL Syntax without .tcl extension

Postby nick. on Fri Oct 05, 2012 5:21 pm

nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Get TCL Syntax without .tcl extension

Postby pnelsonsr on Fri Oct 05, 2012 5:56 pm

I installed the DetectSyntax package using the package controller. I opened up Preferences/Package Settings/DetectSyntax/Settings - User and added

Code: Select all
{
   // if an exception occurs when processing a function, should it be reraised so the user gets feedback? This is really
   // only useful to those writing functions. The average user just wants the plugin to work, so let's not reraise the
   // exception
   "reraise_exceptions": false,

   // If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
   // The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
   // JavaScript syntax, set new_file_syntax to 'JavaScript'.
   "new_file_syntax": false,
   "syntaxes": [
      {
         "name": "TCL",
         "rules": [
            {"first_line": "^#!/usr/bin/tclsh"}
         ]
      }
   ]
}


but it is not working. Any suggestions on what I"m not doing correctly here?
pnelsonsr
 
Posts: 3
Joined: Fri Oct 05, 2012 5:07 pm

Re: Get TCL Syntax without .tcl extension

Postby pnelsonsr on Fri Oct 05, 2012 6:22 pm

OK i fussed around with this and tried getting specific with the language file. I got it working with

Code: Select all
{
   // if an exception occurs when processing a function, should it be reraised so the user gets feedback? This is really
   // only useful to those writing functions. The average user just wants the plugin to work, so let's not reraise the
   // exception
   "reraise_exceptions": false,

   // If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
   // The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
   // JavaScript syntax, set new_file_syntax to 'JavaScript'.
   "new_file_syntax": false,
   "syntaxes": [
      {
         "name": "TCL/Tcl",
         "rules": [
            {"first_line": ""^#!/.*tclsh""}
         ]
      }
   ]
}


Thanks for the DetectSyntax package pointer!
pnelsonsr
 
Posts: 3
Joined: Fri Oct 05, 2012 5:07 pm


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 36 guests