Development takes now place at sourcehut: https://sr.ht/~tomterl/tomtel/ .
This is a generalization of an idea by Mickey Petersen of masteringemacs fame:
Use one keystroke to jump from a code buffer to the corresponding repl buffer and back again.
This works even if you do other stuff in between, as the last buffer used to jump to a repl is stored in a buffer local variable in the repl buffer.
`repl-toggle-mode` will automatically be activated for `prog-mode` major modes and configured and the started repl-buffers.
There are no repl/mode combinations preconfigured, put something like the following in your emacs setup for php and elisp repl:
(setq rtog/fullscreen t)
(require 'repl-toggle)
(setq rtog/mode-repl-alist '((php-mode . php-boris) (emacs-lisp-mode . ielm)))
This defines a global minor mode, indicated with ‘rt’ in the modeline, that
grabs “C-c C-z” as repl toggling key-binding.
I don’t know with which repl modes this actually works. If you use
this mode, please tell me your rtog/mode-repl-alist
, so that I can
update the documentation.
Emacs – of course – has more than one function to switch between
buffers. You can customize rtog/goto-buffer-fun
to accommodate your
needs. The default is switch-to-buffer
; to move focus to another
frame that already shows the other buffer, instead of switching the
current frame to it, use pop-to-buffer
.
(setq rtog/goto-buffer-fun 'pop-to-buffer)
(php-mode . psysh)
(emacs-lisp-mode . ielm)
(elixir-mode . elixir-mode-iex)
(ruby-mode . inf-ruby)
(js2-mode . nodejs-repl)
and(js3-mode . nodejs-repl)
(haskell-mode . intero-repl)
(haskell-mode . haskell-interactive-switch)
(scheme-mode . geiser)
(lisp-mode. slime)
(python-mode . elpy-shell-switch-to-shell)
(typescript-mode . run-ts)
(tuareg-mode . utop)
(sml-mode . sml-prog-proc-switch-to)
(python-mode . run-python)
(nix-mode . nix-repl)
If the mode you want to use doesn’t jump to an existing repl-buffer, but always starts a new one, you can use `rtog/switch-to-shell-buffer’ in your configuration to get that behaviour, e.g. for `octave-mode’:
(rtog/add-repl 'octave-mode (rtog/switch-to-shell-buffer 'inferior-octave-buffer 'inferior-octave))
(rtog/add-repl 'groovy-mode (rtog/switch-to-shell-buffer "*groovy*" 'run-groovy))
When you supply the universal prefix argument to the switching function,
- C-u passes the current line or active region
- C-u C-u passes the current defun
- C-u C-u C-u passes the whole current buffer
to the repl buffer you switch to.
If you set rtog/fullscreen
to true, the repl-commands will be
executed fullscreen, i.e. as single frame, restoring the window-layout
on switching back to the originating buffer.
(setq rtog/fullscreen t)
The custom variable rtog/fallback-repl
can be customized with a
function; this function will be called if no REPL is associated with
the current buffers major mode.
If the custom variable rtog/interactivep
is set to t
, repl-commands
will be called interactively if possible.