Keeping a record of evaluated code

I’m looking to find a workflow where I can keep a record of the code that I evaluate when improvising in a session. That way I can noodle around, then go back over the code, pick and choose the nice bits, clean it up, sequence it musically and try to arrange a track.

Anyone have any suggestions for a workflow like this? Currently I’m using atom-tidal on macOS. So far, I’m thinking that I might be able to do this using the Git-Plus package and some key bindings, but I was curious if anyone had some other ideas.

2 Likes

On Linux there is a command called 'script' that allows you to record a shell session to a file.

The idea is: run script, it gives you back a shell where everything you do is recorded. So I guess you could start ghci inside it and start doing tidal stuff ...

Edit: if it works you would have to modify atom-tidal so it wraps ghci into script

Could be an idea to develop inside the atom plugin

4 Likes

That is an awesome idea

Supercollider has the history class for this: https://doc.sccode.org/Classes/History.html

In emacs there is undo-tree mode. You can configure it to automatically save that history so every edit is saved. I think it is inspired by something in vim.

In feedforward it not only records every keypress but does it with an accurate timestamp. This is currently only used for replaying a previous session, rather than making it editable though.

Sang Won Lee has worked on what he calls 'live writing' in the context of live coding, where you can use a time scrubber with written text to go through history: http://livewriting.cs.vt.edu/?aid=6026abb95cae9504319131c3

I think Clive (https://mathr.co.uk/#clive) has auto git committing built-in for this.

Speaking of undo-tree, I should probably share this code. You can assign a command in Emacs to make trackpad scroll up/down browse undo-tree back/forward and then eval the code when it stops scrolling, essentially giving you a form of code turntablism:

; experiment with these gestures:
;(define-key undo-tree-map [wheel-left] 'tidal-undo-tree-undo-and-run)
;(define-key undo-tree-map [double-wheel-left] 'tidal-undo-tree-undo-and-run)
;(define-key undo-tree-map [triple-wheel-left] 'tidal-undo-tree-undo-and-run)
;(define-key undo-tree-map [wheel-right] 'tidal-undo-tree-redo-and-run)
;(define-key undo-tree-map [double-wheel-right] 'tidal-undo-tree-redo-and-run)
;(define-key undo-tree-map [triple-wheel-right] 'tidal-undo-tree-redo-and-run)

(setq hscroll-margin 0)
(setq hscroll-step 1)

(defun tidal-undo-tree-undo-and-run ()
  (interactive)
  (undo-tree-visualize-undo)
  (undo-tree-tidal-run-multiple-lines))

(defun tidal-undo-tree-redo-and-run ()
  (interactive)
  (undo-tree-visualize-redo)
  (undo-tree-tidal-run-multiple-lines))

(define-key undo-tree-map (kbd "<C-s-return>") 'undo-tree-tidal-run-multiple-lines)

(defun undo-tree-tidal-run-multiple-lines ()
  (interactive)
  (windmove-left)
  (tidal-run-multiple-lines)
  (windmove-right))
3 Likes

Opened an issue to discuss about that for the atom plugin

1 Like

I think it is inspired by something in vim.

in vim you can use something like :earlier 30m (to go back 30 minutes) or :later 1h (to advance 1h)