tmux-vim-demo
run-demo
run
run-racket-demo
run-racket
8.3

tmux-vim-demo

D. Ben Knoble

 #lang tmux-vim-demo package: tmux-vim-demo

This language provides a convenient way to run a demo.

The demo is formed from a running shell and a script. The script is simply a record of commands you may or may not want to send to the shell, so it has some things in common with an actor’s script of lines as well as with a programmer’s program script.

Implementation detail: The script is parsed by the racket reader. The result is mostly ignored, but text which causes the racket reader to error (such as imbalanced parentheses) may cause this language’s reader to bail. My best advice for such issues is currently to use the #; and #| |# commenting forms.

Running a program in this language will spawn a new tmux session with a shell on the left and Vim (in readonly mode by default) on the right. Vim will have two keybindings: Normal-mode r sends the line under the cursor to the shell and moves down a line. Visual-mode r does the same for the visually-selected lines.

If the #:pre directive is given, the corresponding commands will be given to tmux new-session: the shell pane on the left will be replaced with the result of those commands.

If the #:demo? directive is given it controls whether Vim will be in readonly mode. The value #t (the default) means readonly mode while #f means read-write mode.

Keybindings require tpope/vim-tbone to be installed in Vim, or at least a compatible definition of :Twrite. Technically the programs produced by this language will run without it; however, the r keybindings will produce errors.

 

demo

 ::= 

[name]

[dir]

[pre-commands]

[demo]

Script lines ...

 

name

 ::= 

#:name session name (string)

 

dir

 ::= 

#:dir directory for demo (string)

 

pre-commands

 ::= 

#:pre commands for shell (string)

 

demo

 ::= 

#:demo? readonly mode? (boolean)

 (require tmux-vim-demo) package: tmux-vim-demo

The language expands into a call to run-demo and exits with the returned status-code.

procedure

(run-demo name    
  dir    
  filename    
  pre-commands    
  demo?)  byte?
  name : (or/c #f string?)
  dir : (or/c #f string?)
  filename : string?
  pre-commands : (or/c #f string?)
  demo? : boolean?
Runs the demo in a tmux session named name with directory dir. The opened file is filename. Returns the exit code of the tmux invocation.

If name is #f, uses the base-name of filename.

If dir is #f, uses the user’s home directory.

If pre-commands is #f, lets tmux spawn a shell or its default-command. Otherwise, they are given to new-session.

If demo?, run view (Vim in readonly mode). Otherwise, run vim.

procedure

(run name dir filename pre-commands)  byte?

  name : (or/c #f string?)
  dir : (or/c #f string?)
  filename : string?
  pre-commands : (or/c #f string?)
Same as run-demo with demo? being #f.

procedure

(run-racket-demo name dir filename)  byte?

  name : (or/c #f string?)
  dir : (or/c #f string?)
  filename : string?
Same as run-demo with demo? being #t and pre-commands being "racket".

procedure

(run-racket name dir filename)  byte?

  name : (or/c #f string?)
  dir : (or/c #f string?)
  filename : string?
Same as run-demo with demo? being #f and pre-commands being "racket".