Interactive HTML development in Emacs
(require 'moz) (require 'json) (defun moz-update (&rest ignored) "Update the remote mozrepl instance" (interactive) (comint-send-string (inferior-moz-process) (concat "content.document.body.innerHTML=" (json-encode (buffer-string)) ";"))) (defun moz-enable-auto-update () "Automatically the remote mozrepl when this buffer changes" (interactive) (add-hook 'after-change-functions 'moz-update t t)) (defun moz-disable-auto-update () "Disable automatic mozrepl updates" (interactive) (remove-hook 'after-change-functions 'moz-update t))
With this, Firefox will update its HTML contents as you type, for whatever buffer you’ve called moz-enable-auto-update on.
It took about five minutes to write, and another five to comment and put up here. I’ve been using it for a few hours now and haven’t found any real problems.
Edit: You’ll already need mozrepl installed, and the mozrepl emacs integration setup..
Edit: Fixed link. Thanks.