First, I hope you will not mind my poor English. When you're working with websites/webapplications, there is a good chance that you will work with HTML/CSS files. When editing such files in buffers, I save it every time and reload the browser to view my changes (I have a multimonitor setup), which can be quite cumbersome.
It would be awesome when the changes in the buffer you're editing are sent to your web browser as you type. Instantly see the results of editing your HTML without even bothering to save. For that, you have Impatient mode. And there is a demo of it. I appreciate the work that's done, but it's not a perfect solution.
For example, I'm editing webpages within a sort of intranet environment. That's makes it complicated. I will illustrate it with some examples.
foo.html is nested inside another HTML page called
bar.html contains CSS and layout-rules, which will be also applied on the nested html-pages inside
When I I'm editing the page
foo.html, the HTTP server from
impatient-mode will serve live
foo.html inside browser. But I see only a bleak HTML-page without any markup/styling and the structure is not quite right. The styling and definitons of structure are defined in the file
On our intranet, we have a template engine, like Mustache solution. For example, we have some PHP-code:
$foo = "bar";
Then in your HTML-page the template engine is parsing the values from the backend to the frontend.
With that, you will usually see in your browser:
But with the
impatient-mode, you see in your interactive HTML-page:
Instead of bar.
This is because
http-server will be hosting their own page, and doesn't have any notion about the backend/template engine or anything. It's mainly useful for hosting stand-alone pages.
I would love to have real interactive editing that works like a charm. So I guess I need to develop a package for it.
Possible structure for new package
We run a Emacs HTTP server which will run locally on the port 8080 of the localhost.
<script> Hey Javscript engine inside browser, do polling to output of http://localhost:8080/ </script> <html> <div> Your regular HTML page. </div> </html>
Ok, imagine a situation. You're editing some text on line 24 inside a buffer. Then we need a hook that indicates that the user leaves a row. If so, pass the edited row from Emacs buffer to the Emacs HTTP server.
But that's brings us to a new problem. What if the user creates a new line inside buffer, or creates a new line in the middle of of a line? Then Javscript will replace the wrong line.
It could be also a problem when the HTML page is nested into another HTML-page, as illustrated in
Then you're editing a 30 lines HTML page in the Emacs buffer. But in the browser, the whole source code counts more than 100 lines.
I'm thinking about another ways to have a good workflow. But I'm still struggling with connecting the dots, but that's what we programmers are supposed to do, right?
Any another suggestion for connecting the dots would be greatly appreciated.