A JavaScript development environment for Emacs https://indium.readthedocs.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.8 KiB

.. _interaction:
Interaction in JS buffers
Indium comes with a minor mode called ``indium-interaction-mode`` for interactive
programming. To enable it in all JavaScript buffers, add something
like the following to your Emacs configuration: ::
(require 'indium)
(add-hook 'js-mode-hook #'indium-interaction-mode)
When ``indium-interaction-mode`` is on, you can evaluate code, inspect objects and
add or remove breakpoints from your buffers.
Evaluating and inspecting
To evaluate the JavaScript expression preceding the point, press ``C-x C-e``.
To inspect the result of the evaluation of an expression, press ``C-c M-i`` (see
The entire buffer can be evaluated with ``M-x indium-eval-buffer``.
Switching to the REPL buffer
Press ``C-c C-z`` from any buffer with ``indium-interaction-mode`` turned on to
switch back to the REPL buffer (see :ref:`repl`).
Adding and removing breakpoints
You need to first make sure that Indium is set up correctly to use local files
(see :ref:`local-files`).
- ``C-c b b``: Toggle a breakpoint
- ``C-u C-c b b``: Toggle a breakpoint with condition
- ``C-c b K``: Remove all breakpoints from the current buffer
Once a breakpoint is set, execution will stop when a breakpoint is hit, and the
Indium debugger pops up (see :ref:`debugger`).
.. Note:: Breakpoints are persistent: if the connection is closed, when a new
connection is made Indium will attempt to add back all breakpoints.
.. Warning:: When modifying JavaScript buffers, it is up to the user to update
the browser tab. Indium will attempt to update breakpoint locations
when saving a buffer, but the runtime script contents won't be
updated automatically. You can either refresh the page or evaluate
Live code update (hot-swapping JavaScript sources)
Indium supports live code updates without the need to reload the browser tab or
restart the nodejs process.
This feature works with by hot-swapping the script source, and works even with
lexical closures.
.. Note:: This feature currently in only available for Chrome & Chromium.
.. Warning:: Stability issues have been reported when using this feature with
Chrome 57 and earlier. We strongly encourage you to use Chrome >=
58 when using live code updates.
To enable live updates, make sure Indium is set up to use local files (see
- ``C-c C-k``: Updates the runtime JavaScript source with the contents of the
current buffer.
- ``(setq indium-update-script-on-save t)``: Automatically update the runtime
script JavaScript source after each buffer save.