skeeto/skewer-mode — pull request #36 by NateEag (2013-11-16 19:19:37+00:00)
Title: Add stylesheet reloading

First, skewer is awesome. I discovered it last week and fell in love with it. Thank you so much for making it.

When I tried it out at work, I ran into yet another frustration with one of our legacy codebases. That codebase has quite a few messily intertwined stylesheets with hundreds of rules with overly-general selectors. Thus, what I saw while live-editing with skewer didn't necessarily relate at all to what I'd see after a refresh. Sending a whole stylesheet would change its specificity, drastically changing the way a page would render.

As I ate lunch that day, I pondered what it would take to make skewer more useful in a hairball like our codebase. The approach in this merge request occurred to me, so I tried it out, and at least in my simple test case (which should maybe be removed or improved before merging), it seems to work quite well.

`skewer-css` gets a new function called `skewer-css-reload-buffer` that saves the current buffer, then asks all skewer clients to reload the stylesheet whose href best matches the filepath to the current buffer. For the moment, that's bound to `C-c C-r`.

I was thinking it might make sense to make this C-c C-k's default action. If no matching link tag is found, then we could fall back to inserting the stylesheet via style tag. I figured I should get feedback before trying that, though.

This has only been tested in Chrome so far - I'd assume most browsers would behave correctly on removing stylesheets and adding them, but I'm always suspicious of the older IEs.

Any requests, complaints, etc, just ask, and I'll see what I can do.

Again, thanks for skewer! It's awesome, and I hope this can make it awesomer for other people stuck with messes they didn't make.