Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hung-phan/babel-repl
Interactive shell for https://babeljs.io/ in emacs
https://github.com/hung-phan/babel-repl
Last synced: about 10 hours ago
JSON representation
Interactive shell for https://babeljs.io/ in emacs
- Host: GitHub
- URL: https://github.com/hung-phan/babel-repl
- Owner: hung-phan
- Created: 2015-07-11T05:35:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-08T15:46:13.000Z (over 7 years ago)
- Last Synced: 2024-04-10T20:38:40.307Z (7 months ago)
- Language: Emacs Lisp
- Homepage:
- Size: 379 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Babel REPL for emacs
[![MELPA](http://melpa.org/packages/babel-repl-badge.svg)](http://melpa.org/#/babel-repl)
## Acknowledgement
Thanks tmtxt for his plugin [n4js.el](https://github.com/tmtxt/n4js.el)
## Dependencies
- `babel-cli`: `npm install -g babel-cli`
## Installation
### Melpa
[babel-repl](http://melpa.org/#/babel-repl)
### Manual install
- Clone it into your `.emacs.d` and add it into load path
```lisp
(add-to-list 'load-path "~/.emacs.d/babel-repl/")
```### Load the library
- Load the library with `require`
```lisp
(require 'babel-repl)
```### Weird characters workaround
If you get weird characters in your REPL. Add this code snippet to your configuration file.
```lisp
(require 'comint)
(add-to-list 'comint-preoutput-filter-functions
(lambda (output)
(let ((case-fold-search nil))
(replace-regexp-in-string "\033\\[[0-9]+[A-Z]" "" output))))
```## Variables
Change these variables based on your demand
- `babel-repl-cli-program`: the name of babel node cli program, default to
`babel-node`. Change it to absolute path if it's not in your load path.```lisp
(setq babel-repl-cli-program "/path/to/babel-node")
```- `babel-repl-cli-arguments`: the list of arguments to pass to `babel-node`.
- `babel-repl-pop-to-buffer`: whether to pop up the babel shell buffer after sending
command to execute.- `babel-repl-pop-to-buffer-function`: the function used for pop up the babel node
buffer if the above variable is set to t. Default is `pop-to-buffer`. An example
is `pop-to-buffer` to pop up the babel buffer to current window
instead of other window.## Commands
- `babel-repl`: start a babel node process
- `babel-repl-send-current-region`: send the active region to babel node process
- `babel-repl-send-buffer`: send the whole buffer to babel node process
- `babel-repl-send-paragraph`: send the paragraph at point to babel node process
- `babel-repl-send-region-or-buffer`: send the current region if active, otherwise send
the whole buffer to babel node process
- `babel-repl-send-dwim`: send the current region if active, otherwise send the
paragraph at point to babel node process
- `babel-repl-switch-to-buffer`: switch to babel node buffer if exist, otherwise,
start a new one## Connect to a babel shell with option
```lisp
(setq babel-repl-cli-arguments '("--trace-sync-io"))
```## Demo
![Babel shell inside Emacs](interaction.gif)