Closed v2e4lisp closed 11 years ago
netguy204 is the official maintainer for impatient-mode: https://github.com/netguy204/imp.el. That's where MELPA looks for updates. If I accept your pull request, all that would happen is that I make the same pull request for him from my repository.
However, since you involved me I'm going to give you my input. :-) Some improvements should be made before merging and I think netguy204 would agree.
In reference to your imp-format-*
variables: enumerations, especially integer enumerations, are unneeded in Lisp. We have symbols to serve that purpose. Instead of defining variables, just use the names directly as symbols. You don't even need to bother with namespace prefixes for these. On the JavaScript side, handle them as strings.
But I'd take a different route anyway. For any given buffer there should be two handlers established: a pre-transmit formatter (written in Elisp) and a post-transmit client-side formatter (written in JavaScript). Formatters are just functions that accept a string and return a string. Being at the end of the pipeline, the client-side formatter must emit HTML. The client-side formatter is identified by name: the name of the JavaScript function on the client.
When the buffer changes, it's passed through the pre-transmit formatter, then sent to the browser along with the name of the post-transmit formatter. The browser looks up this function and invokes it with the data it received, finally dumping the result into the page.
Next, define an alist that maps modes to the pair of handlers they should initially use.
(defvar imp-formatters
'((html-mode identity "identity")
(markdown-mode identity "showcase")))
The default handlers for any modes not listed is (imp-htmlize-wrapper "identity")
. Finally, imp-toggle
just goes back and forth between the alist handlers and the default handlers.
Anyway, that's how I would do this. It leaves it open in the future for new formatters without having to modify impatient-mode directly again.
What I changed:
added some js code to index.html
Documentation is not modified!