A mode for interacting with a Janet REPL
How to set things up varies a bit depending on how one manages one's Emacs, e.g. straight.el, Doom, etc. What's common to all situations is likely:
-
Ensure janet-ts-mode or
janet-mode
is installed and configured. (If usingjanet-mode
, replacejanet-ts-mode
andjanet-ts-mode-hook
below withjanet-mode
andjanet-mode-hook
respectively.) -
Clone this repository.
- If you cloned to
~/src/ajrepl
, add the following to your.emacs
-equivalent:(add-to-list 'load-path (expand-file-name "~/src/ajrepl")) (require 'ajrepl) (add-hook 'janet-ts-mode-hook #'ajrepl-interaction-mode)
- Add something like the following to your
.emacs
-equivalent:(use-package ajrepl :elpaca (:host github :repo "sogaiu/ajrepl" :files ("*.el" "ajrepl")) :config (add-hook 'janet-ts-mode-hook #'ajrepl-interaction-mode))
- Add something like the following to your
.emacs
-equivalent:(straight-use-package '(ajrepl :host github :repo "sogaiu/ajrepl" :files ("*.el" "ajrepl"))) (use-package ajrepl :straight t :config (add-hook 'janet-ts-mode-hook #'ajrepl-interaction-mode))
- The following might work for Doom:
(package! ajrepl :recipe (:type git :host github :repo "sogaiu/ajrepl" :files (:defaults ("ajrepl/" "ajrepl/*")))) (use-package! ajrepl :after janet-ts-mode :config (add-hook 'janet-ts-mode-hook #'ajrepl-interaction-mode))
- Sorry, no support for that. The manual instructions should work though.
-
Open a Janet file
-
Start an interactive REPL for Janet by
M-x ajrepl
.A buffer for a Janet repl should appear.
-
Various forms of sending things to the REPL should be possible, e.g.
- Send buffer (
C-c C-b
) - Send expression at point (
C-x C-e
) - Send top-level expression at point (
C-M-x
) - Send expression upscoped (
C-c C-u
) - see below for details - Send region (
C-c C-r
)
If Emacs' menus are enabled, there should be a
Ajrepl
menu which shows the above (and other) commands. - Send buffer (
ajrepl-send-expression-upscoped
can be handy when evaluating forms
such as (import ...)
which might otherwise lead to output one might
not be interested in.
There's also a file named ajrepl-experiment.el
that contains some
experimental (aka "may not stick around") functionality.
If the file is required, it should add some additional things to the
Ajrepl
menu. Alternatively, using the "Enable Experimental
Features" menu item under the Ajrepl
menu may work too.
- dylan-hachmann - custom command for starting repl
- sarna - discussion about repl buffer messiness
- sbocq - discussion and code about
eval-defun
-
The REPL buffer gets very messy due to prompt information from
janet
.There are a couple ways this might be mitigated / addressed:
-
There are some commands in
ajrepl-experiment.el
(see above for how to enable) that are an attempt to improve this situation:ajrepl-simplify-repl-prompt
ajrepl-timestampify-repl-prompt
For more details, have a look starting at this issue comment and later.
-
Removing
-s
fromajrepl-start-cmd-line
(which by default is'("janet" "-s")
) as described here.
-