Home Download Buy Blog Forum Support

Convert buffer *right* before it is opened?

Convert buffer *right* before it is opened?

Postby pbakaus on Thu Jan 10, 2013 2:07 pm

Hi all,

the title might be a little confusing, so let me explain.

I'd like to develop a plugin that opens and saves CSS "future-proof". So if the original file content looks like this:

Code: Select all
div {
  -webkit-border-radius: 10px;
  -ms-border-radius: 10px;
  border-radius: 10px;
}


...I would like to display the following to the user:

Code: Select all
div {
  border-radius: 10px;
}


Basically preprocessing the document and folding away anything related to cross browser compatibility.

When saving the altered buffer in Sublime, then do the whole thing reverse: Apply something like Prefixr (http://prefixr.com/) and save the file in the format it was parsed. The idea is to completely fold away complexity and intercept at the right place: The editor.

Now my obvious question: Can this be done with Sublime Text 2? I haven't seen similar plugins.

Thanks much!

Cheers,
Paul
pbakaus
 
Posts: 3
Joined: Thu Jan 10, 2013 1:58 pm

Re: Convert buffer *right* before it is opened?

Postby pbakaus on Wed Jan 16, 2013 1:56 pm

*bump* nobody any idea? really?
pbakaus
 
Posts: 3
Joined: Thu Jan 10, 2013 1:58 pm

Re: Convert buffer *right* before it is opened?

Postby wuub on Wed Jan 16, 2013 2:09 pm

You "can" but this is difficult to detect on_load events that are caused by "Go To anything" showing temporary tabs.

If you modify such tab, you will break goto anything.
If you don't modify it, you won't receive any other events when it's promoted to a "real" tab.

AFAICT there is no way to do this correctly.
You can see how to to this incorrectly here:
http://code.wuub.net/subarwe/src/9f9a84 ... at=default
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: Convert buffer *right* before it is opened?

Postby pbakaus on Sat May 18, 2013 7:59 am

Hi Wojciech,

thanks for the advice! Unfortunately, I'm stuck even earlier than that. I was writing code and used the on_load event to watch for a CSS file getting opened, but as soon as I change anything in the view (i.e. insert, replace etc.), the file gets marked as "modified", which I definitely do not want (basically, what the user modifies and see's should be a compiled source view, unrelated to the actual file on disk).

view.set_scratch(1) after modification does set the view to unmodified visually and doesn't bring up the prompt, but when the user now modifies, that will also not show as modified.

Any idea? I realize I'm trying to do something funky, but this might be really useful to lots of web developers.
pbakaus
 
Posts: 3
Joined: Thu Jan 10, 2013 1:58 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests

cron