This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-10
Channels
- # announcements (6)
- # babashka (38)
- # beginners (85)
- # biff (3)
- # calva (2)
- # cider (11)
- # clerk (14)
- # clj-kondo (6)
- # clj-on-windows (27)
- # clj-together (2)
- # cljsrn (18)
- # clojure (106)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-europe (19)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojure-uk (2)
- # clr (2)
- # cryogen (1)
- # cursive (10)
- # datahike (3)
- # datavis (2)
- # datomic (15)
- # emacs (7)
- # graalvm (10)
- # graphql (20)
- # gratitude (1)
- # hyperfiddle (1)
- # improve-getting-started (23)
- # joyride (24)
- # london-clojurians (1)
- # lsp (22)
- # malli (4)
- # matcher-combinators (3)
- # membrane (13)
- # off-topic (1)
- # pathom (24)
- # polylith (9)
- # react (31)
- # reagent (9)
- # releases (1)
- # remote-jobs (1)
- # reveal (3)
- # shadow-cljs (50)
- # spacemacs (3)
- # specter (5)
- # xtdb (5)
I feel like I am leaving value on the table through the clumsiness of how I access and manipulate the history of my interactions with the repl. I should be able to see and re-execute prior expressions, but since I send everything to the repl by evaluating code within its context in the source code rather than by typing into a repl, The cider history mode shows me nothing. Any thoughts on this?
I would like understand what value an expression by expression history would provide so I can understand what I may be missing. To me the source code buffers are the repl history (without the repeated evaluations of very similar things). When using Cider to evaluate code in a source code buffer, a marker in the margin (gutter) indicates it was evaluate. If the code is changed, the marker is removes so I know the function is different to what is evaluated in the REPL. When I want to remember the shape of data that a function returns I'll print the evaluation result as a comment. Or for larger results I'll use the cider inspector, which will update each time a function is evaluated if it's buffer is kept open. Or I'll connect Portal data inspector and do the same. If I am evolving the design of a function, then I keep a design journal. I create a rich comment with different versions of a function (or functions) to help determine what design choices I want to make. I usually start the rich comment in the same namespace and migrate any code I want to keep into a separate namespace when I am done. If I am breaking ground on a completely new challenge or new set of libraries, I my start the design journal in a separate namespace (still in a comment so it doesn't get loaded unless I want it too) If the experiments are valuable I'll keep them in the project but move them to a path that is outside the normal class path used for the project, e.g. develop, defining an alias I can optionally use when running the reply to include these experiments on the class path. Before the comment form I add a directive to tell clj-kondo to ignore duplicate definitions which I added as a Clojure LSP snippet for convenience Are there further things I could do with the repl history? I must admit that I rarely use a repl prompt directly, except for separation of long running processes or interacting with component lifecycles (start/refresh/stop).
I use comment blocks too, but sometimes I jump around in files and evaluate comment blocks in several different files, and then I lose track of my history.
As far as I know the only way to have a repl buffer history is to use the repl buffer, sending each evaluation to the repl buffer. Then the history can be scrolled. I assume it would be possible to write an elisp function that calls both evaluate in the source code buffer and send expression to repl buffer cider commands. Then add a different key bindings for this function.
(advice-add
#'cider-nrepl-request:eval
:before
(defun my-cider-add-evals-to-history (input callback &optional ns line column additional-params connection)
(let ((connection (or connection (cider-current-repl nil 'ensure))))
(with-current-buffer connection
(cider-repl--add-to-input-history input)))))
sounds like you want to add to the history when evaling