netguy204 / imp.el

Impatient html mode. See your changes in the browser as you type
http://www.youtube.com/watch?v=QV6XVyXjBO8
137 stars 28 forks source link

Question: can a custom filter determine whether the page will be updated or not? #20

Open fehmud opened 10 years ago

fehmud commented 10 years ago

Hello Brian,

thanks for writing and sharing this useful package.

I wonder if the value returned by a custom filter can determine whether the web page will be updated or not, because the buffer could contain incomplete code and therefore showing the resulting web page would not make sense.

Thanks for your attention.

netguy204 commented 10 years ago

@egarrulo, patches welcome. There's no implementation of what you suggest right now. Such an implementation would probably need to live in imp--send-state and could be based on the return value of the custom filter (which is currently ignored.)

The code path to imp--send-state currently assumes that the client will get something and then reconnect to the server for whatever's next. When a filter declines to update you can send the client something that indicates that (and add a special case to the client) or you can get rid of the "client always gets something" assumption in the loop that calls imp--send-state.

fehmud commented 10 years ago

Thanks for your prompt reply.

Unfortunately, I have read the code and at the moment my Emacs Lisp skills are enough to patch the code like you have described. As a quick fix, users could save the filtered output in a buffer-local variable, and output its last value in case the new filtered output must be discarded. And since Impatient Mode hangs in case an error escapes the filter, users should also catch all errors in the filter and output the saved value.

Thanks for your attention.