Skip to content

Instantly share code, notes, and snippets.

@nonsequitur
Created June 17, 2010 16:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nonsequitur/442376 to your computer and use it in GitHub Desktop.
Save nonsequitur/442376 to your computer and use it in GitHub Desktop.
(require 'moz)
;;; Usage
;; Run M-x moz-reload-mode to switch moz-reload on/off in the
;; current buffer.
;; When active, every change in the buffer triggers Firefox
;; to reload its current page.
(define-minor-mode moz-reload-mode
"Moz Reload Minor Mode"
nil " Reload" nil
(if moz-reload-mode
;; Edit hook buffer-locally.
(add-hook 'post-command-hook 'moz-reload nil t)
(remove-hook 'post-command-hook 'moz-reload t)))
(defun moz-reload ()
(when (buffer-modified-p)
(save-buffer)
(moz-firefox-reload)))
(defun moz-firefox-reload ()
(comint-send-string (inferior-moz-process) "BrowserReload();"))
@bobdobbs
Copy link

bobdobbs commented Nov 7, 2010

Please let me know if I should be posting this elsewhere:

This mode lets me do something awesome.
However, the default is to do a reload whenever the buffer has been altered. This causes the browser to flash as I'm typing. It's distracting and annoying.

Is there a way to alter this, so that the browser reloads only when I save the buffer?
Thanks.

@nonsequitur
Copy link
Author

This reload-as-you-type behaviour is actually intended. I find it very convenient.
Here's a slight modification of the above code which restricts reloading to trigger only when the buffer is saved.
moz-reload-on-save-mode.el, https://gist.github.com/666092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment