Setting up emacs for janet
requirements
well, obviously you are required to have janet installed. no janet, no janet-mode. and git for emacs' straight package manager:
windows
i recommend using [cygwin] or whatever linux-userland you like. perhaps you can even use [portacle] and have common lisp, emacs lisp and janet in one editor with minimal work... found portacle to sometimes misbehave, but cant remember what exactly bothered me so much.. perhaps i was just fed up with emacs at the time as the keystrokes are always a handful
also windows but not emacs
other editors like vscode look more polished. if you dont mind having vscode spike your gpu up to 30% at times from just scrolling up and down rapidly (ok... granted, this was observed on an amd ryzen 7 pro 4750U... so if you have a beefier gpu:), it might be actually for you. and vscode is also pretty neat in configurability. but at times it annoys the heck out of me with its toaster-popups (i actually want to be notified about some of those but you can only turn all of them off last time i checked...)
general instructions for setting up interactive and normal janet mode in emacs:
- install emacs
- put the following into your ~/.emacs file:
(require 'comint)
(defvar bootstrap-version)
(let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent
'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package
'(janet
:type git
:host github
:repo "ALSchwalm/janet-mode"))
(straight-use-package
'(ijanet
:type git
:host github
:repo "SerialDev/ijanet-mode"))
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(global-display-line-numbers-mode t)
'(size-indication-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
recommended modifications
you can modify this code to use my forks of those repos (replace SerialDev
and ALSchwalm
above with kamisori, or even your own github username if you want to use your own fork :), as the keybindings have been commented out by the original author. (you can find the commented lines in ~/.emacs.d/straight/repos/ijanet-mode/ijanet.el
at the bottom end. perhaps the author decided it best to move those into their .emacs but that is just a guess.)
usage
now whenever you restart emacs and are in need of a janet REPL you will initially have to start it using M-x ijanet
but after the initial run if only the janet repl is exited from, you can reinvoke the REPL with C-c C-p
from inside an open *.janet file.
to send a region of code use C-c C-r
and to send just the current line C-c C-l
but i found the region method to work best.
ijanet-mode in theory also can send the whole buffer using C-c C-b
, but that doesnt seem to work... sometimes? i got a message a la "mark not set" when i tried it but ymmv.