Skewer is available from MELPA, which will install the dependencies for you. This package and its dependencies are pure Elisp, meaning setup is a breeze, the whole thing is highly portable, and it works with many browsers.
Skewer requires Emacs 24.3 or later.
If Skewer was installed from MELPA, skip to step 3.
- Put this repository directory in your
- Load skewer-mode.el
run-skewerto attach a browser to Emacs
- From a
skewer-modeminor mode enabled, send forms to the browser to evaluate
skewer-setup can be used to configure all of mode hooks
(previously this was the default). This can also be done manually like
(add-hook 'js2-mode-hook 'skewer-mode) (add-hook 'css-mode-hook 'skewer-css-mode) (add-hook 'html-mode-hook 'skewer-html-mode)
The keybindings for evaluating expressions in the browser are just
like the Lisp modes. These are provided by the minor mode
- C-x C-e: Evaluate the form before the point and display the result in the minibuffer. If given a prefix argument, insert the result into the current buffer.
- C-M-x: Evaluate the top-level form around the point.
- C-c C-k: Load the current buffer.
- C-c C-z: Select the REPL buffer.
The result of the expression is echoed in the minibuffer.
html-mode get similar sets of bindings
for modifying the CSS rules and HTML on the current page.
- C-x C-e: Load the declaration at the point.
- C-M-x: Load the entire rule around the point.
- C-c C-k: Load the current buffer as a stylesheet.
- C-M-x: Load the HTML tag immediately around the point.
browse-url to launch the browser. This may
require further setup depending on your operating system and personal
Multiple browsers and browser tabs can be attached to Emacs at once.
each will echo back the result individually. Use
to see a list of all currently attached clients.
Sometimes Skewer's long polls from the browser will timeout after a
number of hours of inactivity. If you find the browser disconnected
from Emacs for any reason, use the browser's console to call
skewer() to reconnect. This avoids a page reload, which would lose
any fragile browser state you might care about.
To skewer your own document rather than the provided blank one,
- Load the dependencies
- Start the HTTP server (
- Include "http://localhost:8080/skewer" as a script
(see example.html and check your
- Visit the document from your browser
Skewer fully supports CORS so the document need not be hosted by Emacs itself. A Greasemonkey userscript is provided for injecting Skewer into any arbitrary page you're visiting without needing to modify the page on the host. More information below.
skewer.js anywhere or use it directly. Emacs hosts
this script itself, manipulating it in memory before it reaches the
browser. Always access it through the servlet on the Emacs webserver
Skewer is known to work properly with Firefox, Chrome, Safari, Opera,
and IE8+. Except for CSS and HTML, Skewer will work in IE7 when
JSON are polyfilled. If you find any
please report it.
A REPL into the browser can be created with
M-x skewer-repl, or
C-c C-z. This should work like a console within the
browser. Messages can be logged to this REPL with
Results of expressions evaluated in the REPL are printed more verbosely than in the minibuffer, when possible. This may help in debugging.
Skewer supports Cross-origin Resource Sharing (CORS). This
means you can Skewer a document hosted from any server without needing
any special changes on that server, except for including
a script in that document.
If you don't control the server from which you want to skewer pages -- such that you can't add the Skewer's script -- the provided Greasemonkey userscript can be used to inject it into any page you visit. Note that this userscript will assume you're running the Skewer server at http://localhost:8080/ (simple-httpd's default port). If this isn't true, you need to edit the top of the userscript.
The script isn't actually injected until you switch the toggle in the top-right corner, the red/green triangle.
Alternatively, the following bookmarklet will load skewer on demand:
Also provided are some functions for loading libraries from the bower
infrastructure on the fly. This is accessed with
For example, I often find it useful to load jQuery when skewering a
page that doesn't have jQuery installed.
Note: to use this bower does not need to be installed, only git. It's just the bower infrastructure being used. Unfortunately this infrastructure is a mess right now; many packages are in some sort of broken state -- missing dependencies, missing metadata, broken metadata, or an invalid repository URL. Some of this is due to under-specification of the metadata by the bower project.
I wanted something like swank-js but without all the painful setup. Having already written an Emacs web server I was halfway there. It took relatively little code to accomplish.
I also didn't want to rely a browser-specific feature, like MozRepl or WebKit's remote debugger (kite).
The name refers to the idea that Emacs is skewering the browser from server-side.