motform / reveal-remote-mode

use emacs to remote control reveal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOTE: CURRENTLY LIMITED TO CIDER

reveal-remote-mode

reveal-remote-mode is an Emacs minor mode for remote controlling Reveal, the “Read Eval Visualize Loop” for Clojure. It leverages the evaluated command form interface to afford the user convenient access to window control features and view opening. The package is still in an early state, so any feedback is appreciated.

The mode currently relies on CIDER and has only been tested on JVM Clojure via nrepl. The goal is to make it compatible with inf-clojure and other repls in the future.

Note that reveal-remote-mode does not provide any kind of view-type validation, meaning you are free to request a view that is incompatible with the form you are sending, resulting in an exception. This is not a problem per see, but could be good to know.

For more information about Reveal, head over to the docs.

Setup

Until the mode is published on a package repository I recommend using straight.

(use-package reveal-remote
  :straight (reveal-remote :type git :host github :repo "motform/reveal-remote-mode")
  :hook (cider-mode . reveal-remote-mode))

Adding Views

Available views are set in the reveal-remote-views alist. reveal-remote expects the CAR of the pair to be user facing name (preferably the same one registered in Reveal) and the CDR to be the fully namespace qualified key under which the view was registered.

(add-to-list 'reveal-remote-views '("view:new" . ":fully.qualified.namespace/key"))

For example, if one wanted to add phronmophobic’s reveal-treemap, one would have to add the view to reveal-remote-views, taking care to fully qualify the key:

(add-to-list 'reveal-remote-views '("treemap" . ":com.phronemophobic.reveal-treemap/treemap"))

Followed by requiring the namespace in your REPL:

(require 'com.phronemophobic.reveal-treemap)

Doing this should populate the view’s list with the now evaluated treemap, ready to inspect!

Configuration

reveal-remote-mode exposes two meaningful variables: the interrelated reveal-remote-eval-in-other-ns and reveal-remote-other-ns. By default Reveal evaluates the received form (and thus all sub forms) in the vlaaad.reveal.ext namespace, causing any unknown symbols to result in compile errors (as per regular Clojure semantics). We can configure this behavior using the :ns key, which reveal-remote-mode defaults to whatever is in *ns*. Setting reveal-remote-eval-in-other-ns allows you to toggle this behaviour (default t), reveal-remote-other-ns allows you to specify the value of :ns.

In addition to these, there is also a list called reveal-remote-views that enumerates the possible Reveal views. This is the place where you would add custom views.

VariablesValues
reveal-remote-eval-in-other-nst (default), nil
reveal-remote-other-ns*ns* (default), any valid Clojure namespace (string)
reveal-remote-envany valid Clojure form (string), nil (default)
reveal-remote-viewsAlist of Reveal views

Keymap

The keymap defaults to the prefix C-c C-a. You can change this by setting reveal-remote-mode-keymap-prefix.

KeyFunction
C-c C-a lreveal-remote-clear
C-c C-a qreveal-remote-close-all-views
C-c C-a xreveal-remote-dispose
C-c C-a ereveal-remote-submit
C-c C-a vreveal-remote-open-view-last-sexp
C-c C-a creveal-remote-open-view-defun-at-point

Roadmap

  • Add view-type validation.
  • Add a .gif or screencast to persuade the kids.

About

use emacs to remote control reveal

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 100.0%