Refresh Firefox page from Emacs

by Ruslan Spivak on March 16, 2009

I often need to refresh page in Firefox when I edit page template or javascript file. This is especially true when working on grok-awesome.

Though I use tiling window manager StumpWM and it’s very easy to switch to running Firefox with keyboard shortcut and make refresh, it’s even easier not to leave focus from Emacs window and just send command to Firefox to refresh itself.
For that I use:

  • MozRepl firefox plugin to allow connect to Firefox’s REPL. After installation in Tools -> MozRepl menu I chose ‘Activate on startup’ for convenience
  • MozRepl Emacs integration (If you use nXhtml package in Emacs you already have that integration and can skip this part)

Command to refresh Firefox is BrowserReload();

Final touch is small anonymous function to send that command to mozrepl, keybinding to C-x p and we’re all set:

(global-set-key (kbd "C-x p")
                (lambda ()
                  (interactive)
                  (comint-send-string (inferior-moz-process)
                                      "BrowserReload();")))

Now anytime just press C-x p and refresh command will be sent to Firefox starting along the way mozrepl session in your Emacs if it’s not been already started.

If you enjoyed this post why not subscribe via email or my RSS feed and get the latest updates immediately. You can also follow me on GitHub or Twitter.

{ 1 comment… read it below or add one }

geocar March 17, 2009 at 8:11 AM

Speak your mind

Previous post:

Next post: