Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 3.41 KB

README.org

File metadata and controls

62 lines (47 loc) · 3.41 KB

ngnk-mode

This contains a pretty bare bones swipe at an emacs command interpreter for editing ngn/k as well as an even more bare-bones major mode for editing ngnk.

Most of this doc describes ngnk-cli which is the emacs wrapper for the command interpreter. The main use of the major mode currently is to be used in conjunction with an equally bare bones LSP server.

Set up

Put ngnk-cli.el somewhere in your load-path (probably $HOME/emacs/lib) and add the following to your .emacs file:

(require 'ngnk-cli)

That should do it.

Running K

To start a session, simply call M-x run-ngnk which will create a buffer called *Ngnk*, which you can use as a repl.

From any other buffer, you can send the selected region to the *Ngnk* buffer with (ngnk-send-region). You can bind that to a key combo by adding something like the following to your .emacs file:

(global-set-key (kbd "C-c C-k") (lambda () (interactive) (ngnk-send-region)))

Customization

  • Ngnk Cli File Path: Path to the executable. Defaults to a bare “k” which is searched for in your exec-path
  • Ngnk Cli Arguments: List of arguments to pass to the k executable. Defaults to the repl.k file in the same directory as the exectuable.
  • Ngnk Max Output Length: [ DEPRECATED ] Length at which to clip output. Setting to 0 does no clipping.
  • Ngnk Start File: File to load on startup. This is file is delivered to the executable as if you typed it in immediately after start up.
  • Ngnk Mark Line Continuations: Send eol escape sequences when sending a region to the buffer

Sytnax Highlighting

This is currently available through the ngn/k lsp server and is a work in progress.

Note about Ngnk Max Output Length

[ DEPRECATED: This functionality is now found in repl.k directly ] The output from k is delivered in 1K chunks but emacs has no way to know when the “full output” of the command you entered is done. To take make this work you need to add 0x07 to the start of your prompt as a signal to emacs that it’s done with the output. This is currently the default, but you can remove this by putting the following at the start of your startup file:

repl.prompt:," "

If you don’t make this change you should definitely leave Ngnk Max Output Length to 0 as otherwise it will totally confuse the function handling this.

Note about Ngnk Mark Line Continuations

By default the ngn/k repl is line oriented, so if you try to enter a multi-line definition of a function or an array it will complain. To get around this we can send escape sequences with each newline we don’t want to represent the end of a command so that the repl may collect these lines instead of processing them individually. This configuration optionally turns that on.

Note that this is mostly for use with ngnk-send-region and multi-line selections. You can use nl escapes directly in the repl but it trips up the emacs side of the connection since with each line entered it waits for a response from the process even as the process is waiting for more input. You can kill this deadlock with C-g but mostly it’s not even worth attempting.