Fork me on GitHub
#cider
<
2024-04-26
>
diego.videco20:04:33

Is there a way to record/save the forms that have been evaluated with cider-eval-defun-at-point ? For context I often do live coded music performances and would like to be able to save the evaluated forms with timestamps for replaying them at a later time or for reference.

vemv20:04:01

I'd look into advice-add ing that function - in your hook you can do the persistence work

diego.videco02:04:04

sorry, which hook?

iarenaza09:04:33

What vemv called "your hook" is the function you would "attach" to advice-add. You would define your own function (let's call it my/archive-cider-eval-defun-at-point)), to take the "form" being evaluated by cider-eval-defunt-at-point, attach whatever metadata you want to keep next to that form (e.g., a timestamp), and save (archive) all that to the place you want to (a file, a database, wherever). And then you would advice cider-eval-defun-at-point, using advice-add with my/archive-cider-eval-defun-at-point. You'll probably be interested in using :around (although :filter-return may suffice for this case) with addvice-add. So you can check if cider-eval-defun-at-point successfully evaluated the "form", before archiving it (I'm assuming you don't want to archive forms that had evaluation errors).

💯 1
diego.videco15:04:46

Thank you both @U45T93RA6 and @U8T05KBEW!

🙌 1