Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomterl/repl-toggle
Switch to/from repl buffer for current major-mode
https://github.com/tomterl/repl-toggle
emacs emacs-lisp
Last synced: 3 months ago
JSON representation
Switch to/from repl buffer for current major-mode
- Host: GitHub
- URL: https://github.com/tomterl/repl-toggle
- Owner: tomterl
- Archived: true
- Created: 2013-06-11T07:15:43.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-02-22T08:14:20.000Z (over 3 years ago)
- Last Synced: 2024-04-14T22:23:05.665Z (3 months ago)
- Topics: emacs, emacs-lisp
- Language: Emacs Lisp
- Homepage:
- Size: 56.6 KB
- Stars: 22
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Lists
- awesome - repl-toggle - Switch to/from repl buffer for current major-mode (Emacs Lisp)
README
Development takes now place at sourcehut: https://sr.ht/~tomterl/tomtel/ .
* Switch from code buffers to the corresponding REPL
[[http:/stable.melpa.org/#/repl-toggle][file:http://stable.melpa.org/packages/repl-toggle-badge.svg]]
[[http://melpa.org/#/repl-toggle][file:http://melpa.org/packages/repl-toggle-badge.svg]]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:#+BEGIN_SRC emacs-lisp
(setq rtog/fullscreen t)
(require 'repl-toggle)
(setq rtog/mode-repl-alist '((php-mode . php-boris) (emacs-lisp-mode . ielm)))
#+END_SRCThis 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.** ~pop~ or ~switch~: ~rtog/goto-buffer-fun~
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)~
** Configurations known to work
- ~(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)~*** Switch to shell buffer
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':**** ~octave~
#+BEGIN_SRC emacs-lisp
(rtog/add-repl 'octave-mode (rtog/switch-to-shell-buffer 'inferior-octave-buffer 'inferior-octave))
#+END_SRC**** ~groovy~
#+BEGIN_SRC emacs-lisp
(rtog/add-repl 'groovy-mode (rtog/switch-to-shell-buffer "*groovy*" 'run-groovy))
#+END_SRC** Pass code at point to the REPL
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 bufferto the repl buffer you switch to.
** fullscreen REPL
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)~
** Fallback REPL functionThe 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.** Call repl-commands interactively
If the custom variable =rtog/interactivep= is set to =t=, repl-commands
will be called interactively if possible.