skeeto / impatient-mode

Impatient html mode. See your changes in the browser as you type
215 stars 19 forks source link

Implemented improvements to delayed updating #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

Implemented improvements to delayed updating from @skeeto. https://github.com/netguy204/imp.el/pull/37

skeeto commented 6 years ago

Thanks! I did some heavy refactoring of your code, but kept some of the names and a bit of the structure. I also took some time to bring this project up to speed since it had gotten kind of neglected over the years.

One of the things I did outside of your change was fix up the Makefile to be useful. The header documents what else you need to do to make it work. What's important about this is that it byte-compiles the code, which also performs a bit of static analysis as a side effect. It warned about a couple of mistakes in your code: setting an undefined variable and calling a non-existent function.

There are seems to be no official way to get the timing information from a timer object. I see you found timer--time, which is pretty impressive for someone new to Elisp. However, that double dash is a convention that indicates this function/macro is private, not intended to be used by other packages. So instead the timer is stored as a cons, with the car element being the time it was created with and the cdr being the actual timer object. It just means impatient-mode tracks the time externally to the timer object rather than call a private function.

I also flattened the timer updating logic into a cond in imp--start-idle-timer (maybe not the best name).

In my tests everything seems to work fine. When I updated the Makefile I also added a "run" target, which starts Emacs unconfigured (-Q) with impatient-mode loaded and running.

MELPA still points at @netguy204's repository. If that's still the case for much longer, I may go bug him to pull all this new stuff into his repository. (Or he might just do that himself since I said his name, wink wink.)