Home Download Buy Blog Forum Support

Shebang Syntax

Shebang Syntax

Postby vxnick on Wed Mar 21, 2012 8:23 pm

Hi All,

This is my first post as well as my first Sublime plugin, so please be gentle :-)

This plugin is pretty straightforward - it sets a file's syntax based on a shebang line during file load and save (i.e. '#!/usr/bin/env python' to Python). From what I've seen, this already exists in the core, but not to the extent that it handles 'env' as the binary, with the actual binary (such as 'python') as an argument to env.

Essentially, the plugin capitalises the first character of the binary it finds and matches that against syntax directories and files in the Packages directory. In some cases, this won't work ('PHP' is all upper-case, Bash is 'ShellScript/Shell-Unix-Generic.tmLanguage') - when this is the case, simply add those to the plugin settings file. This also works if you have additional binaries that need to use the same syntax - an example being 'python2' and 'python3' needing to use the Python syntax.

More info can be found here - I'm currently waiting for the plugin to be added to Will Bond's Package Control.

Any issues, please raise them on GitHub :-)
vxnick
 
Posts: 6
Joined: Wed Mar 21, 2012 8:14 pm
Location: Portsmouth, UK

Re: Shebang Syntax

Postby phillip.koebbe on Wed Mar 21, 2012 9:45 pm

Hi vxnick,

I definitely don't want this to come across the wrong way, but did you give DetectSyntax [1] a try before writing your own plugin? Identifying syntax by a shebang was one of the things I wanted to accomplish with DetectSyntax, and if you tried it and it doesn't work for you, I'd like the chance to fix it.

On the other hand, if you just wanted to write your own plugin, that's great! The more people writing quality plugins the better! So please don't take this the wrong way.

[1] https://github.com/phillipkoebbe/DetectSyntax
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Shebang Syntax

Postby vxnick on Thu Mar 22, 2012 9:40 am

Hi Phillip,

I didn't try it, but I found your plugin about halfway through developing mine so thought I'd finish it anyway :-)

It was more an experiment with the Sublime plugin API than anything serious, so no offence taken!
vxnick
 
Posts: 6
Joined: Wed Mar 21, 2012 8:14 pm
Location: Portsmouth, UK

Re: Shebang Syntax

Postby tito on Thu Mar 22, 2012 10:53 am

If something is going wrong with Phillip package you better try to fix it by communicating, there is no gain into having two packages doing "the same".
Confuse people and is a waste of valuable resources and time.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 878
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Shebang Syntax

Postby bizoo on Thu Mar 22, 2012 11:01 am

tito wrote:If something is going wrong with Phillip package you better try to fix it by communicating, there is no gain into having two packages doing "the same".
Confuse people and is a waste of valuable resources and time.

+1000
There are more and more package in Package Control that do almost the same things.
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Shebang Syntax

Postby vxnick on Fri Mar 23, 2012 8:53 am

bizoo wrote:There are more and more package in Package Control that do almost the same things.


Any examples? I've looked and can't find anything similar other than DetectSyntax. I've already given my reasons why I finished developing this plugin (I hadn't found DetectSyntax at the time).
vxnick
 
Posts: 6
Joined: Wed Mar 21, 2012 8:14 pm
Location: Portsmouth, UK

Re: Shebang Syntax

Postby tito on Fri Mar 23, 2012 9:16 am

The point is to try to unite efforts to get the problems solved. Not 123234 ways to resolve it. This community seems to not understand that.
If your package is not doing nothing that DetectSyntax can't do, then why you submitted the package to package control?
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 878
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Shebang Syntax

Postby bizoo on Fri Mar 23, 2012 9:30 am

vxnick wrote:I've looked and can't find anything similar other than DetectSyntax. I've already given my reasons why I finished developing this plugin (I hadn't found DetectSyntax at the time).

Nobody prevent you to write your plugins and use them, the problem is when you want to publish them on Package Control.

The Package Control repository grow very quickly, and having dozen of plugins with almost the same functionality is bad for both new and confirmed users.
Searching and testing plugins is time consuming...

Github make collaborative coding simpler than it ever was, it's a pity that people don't use it more often.

I use a bunch of plugins from Package Control and a dozen of my own plugins.
When I think something missing on a plugin from Package Control, I write an issue on github or send a pull request.
If you think that something missing on the DetectSyntax plugin, as already asked by phillip.koebbe write an issue or make a pull request.

The reasons why you wrote your plugin and ask to publish it on Package Control is perfectly fine, but now you know that DetectSyntax exist, do you still think that your plugin must be published ?

vxnick wrote:Any examples?

Code Alignment:
https://github.com/khiltd/Abacus
http://wbond.net/sublime_packages/alignment
https://github.com/wbond/package_contro ... l/pull/226

Files 'management':
https://github.com/belike81/Sublime-File-Navigator
https://github.com/wbond/package_contro ... l/pull/229

Code execution:
https://github.com/darinmorrison/sublime-meta
https://github.com/technocoreai/SublimeExternalCommand
https://github.com/wbond/package_contro ... l/pull/227
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Shebang Syntax

Postby vxnick on Fri Mar 23, 2012 11:29 am

Hi,

Sorry, those plugins don't look related at all to mine or DetectSyntax unless I'm missing something.

Either way, people don't have to use my plugin - I developed it as a fun sideline and it does just one thing pretty well. I think it's fair to say that some people don't know regex and don't want to have to learn it in order to detect a file's syntax based upon a shebang line. For others, like us, it's not a problem adding that to DetectSyntax's settings.

To answer your question though - I feel my plugin meets the needs of end-users who aren't necessarily proficient enough (or can't be bothered) to write the regex for detecting this as part of DetectSyntax. Phillip's plugin is clearly better than mine, but I think they serve different purposes. If I was emulating pretty much everything that DetectSyntax was, then I'd agree with you :-)

Anyway, if Will Bond decides that my plugin isn't suitable for Package Control then that's fine - if nobody uses it other than me, that's fine too. I just wanted the opportunity to let other people know it existed in case they were looking for something simple.

P.S. I expect this plugin to be a stop-gap solution anyway, until Sublime properly interprets shebang lines.
vxnick
 
Posts: 6
Joined: Wed Mar 21, 2012 8:14 pm
Location: Portsmouth, UK

Re: Shebang Syntax

Postby bizoo on Fri Mar 23, 2012 1:20 pm

vxnick wrote:Sorry, those plugins don't look related at all to mine or DetectSyntax unless I'm missing something.

Sorry maybe I wasn't clear (or maybe my poor english), these examples was not related to your package, but to illustrate the point that there is already kind of duplicate packages in Package Control.
And I'm not saying there is something wrong with any of these packages.
vxnick wrote:I feel my plugin meets the needs of end-users who aren't necessarily proficient enough (or can't be bothered) to write the regex for detecting this as part of DetectSyntax. Phillip's plugin is clearly better than mine, but I think they serve different purposes. If I was emulating pretty much everything that DetectSyntax was, then I'd agree with you

So your issue with DetectSyntax is that it use regex, right ?
I'm pretty sure that phillip.koebbe can add something like "first_line_noregex" to is config file in less that five minutes.. if he want... and if you ask him...
vxnick wrote:Anyway, if Will Bond decides that my plugin isn't suitable for Package Control then that's fine

I totally disagree with this view.
It's not the job of wbond to check every package that people want to be added to Package Control, with the current trend it will a full time job in a few months...
This is a community driven repository so people could and have to give their opinions about its content, and this is why three people already ask you to think about it's inclusion in Package Control.

And don't get me wrong, I've nothing personal against you or your code, actually your code is very good and well commented.
I expect to see more of your plugins in Package Control in future, simply not this one... ;)

Cheers,
Dominique
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 14 guests