{"id":27389266,"url":"https://github.com/vvvvalvalval/scope-capture-nrepl","last_synced_at":"2025-04-13T19:13:38.816Z","repository":{"id":52636160,"uuid":"106184229","full_name":"vvvvalvalval/scope-capture-nrepl","owner":"vvvvalvalval","description":"nREPL middleware for scope-capture","archived":false,"fork":false,"pushed_at":"2019-01-25T17:51:33.000Z","size":13,"stargazers_count":30,"open_issues_count":4,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-17T05:29:21.120Z","etag":null,"topics":["clojure","nrepl-middleware","repl","tooling"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vvvvalvalval.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-08T14:49:41.000Z","updated_at":"2023-06-14T18:30:22.000Z","dependencies_parsed_at":"2022-08-21T23:01:08.882Z","dependency_job_id":null,"html_url":"https://github.com/vvvvalvalval/scope-capture-nrepl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvvvalvalval%2Fscope-capture-nrepl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvvvalvalval%2Fscope-capture-nrepl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvvvalvalval%2Fscope-capture-nrepl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvvvalvalval%2Fscope-capture-nrepl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vvvvalvalval","download_url":"https://codeload.github.com/vvvvalvalval/scope-capture-nrepl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766748,"owners_count":21158301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","nrepl-middleware","repl","tooling"],"created_at":"2025-04-13T19:13:38.369Z","updated_at":"2025-04-13T19:13:38.806Z","avatar_url":"https://github.com/vvvvalvalval.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scope-capture-nrepl\n\n[![Clojars Project](https://img.shields.io/clojars/v/vvvvalvalval/scope-capture-nrepl.svg)](https://clojars.org/vvvvalvalval/scope-capture-nrepl)\n\nA companion library to [scope-capture](https://github.com/vvvvalvalval/scope-capture), providing an nREPL middleware that lets you put your REPL in the context of an Execution Point (via `sc.api/letsc`). \n\nProject status: alpha quality. Tested empirically on Cursive. OTOH, this is typically only used in development,\n and for most purposes you can just falling back to using the raw API of scope-capture.\n\n**NOTE:** this middleware is only suitable for programs where the REPL and the nREPL middleware run in the same process \n (typically JVM Clojure, typically not JVM-compiled ClojureScript.)\n\n## Installation\n\nThis library exposes an [nREPL middleware](https://nrepl.org/nrepl/design/middleware.html) in the Var `sc.nrepl.middleware/wrap-letsc`.\n\nIt works with both the [nREPL](https://nrepl.org/nrepl/index.html) library and the older [tools.nrepl](https://github.com/clojure/tools.nrepl):\n you must provide these dependencies separately.\n\n#### Via deps.edn\n\nYou need to declare dependencies both to this library and to nREPL itself.\n You'll typically want to put them in a custom profile, as [recommended](https://nrepl.org/nrepl/usage/server.html#_using_clojure_cli_tools) by the nREPL documentation:\n\n```clojure\n;; in your deps.edn file:\n{\n ;; [...]\n :aliases\n {\n  ;; [...]\n  :nREPL\n  {:extra-deps\n   {nrepl/nrepl {:mvn/version \"0.5.3\"}\n    vvvvalvalval/scope-capture-nrepl {:mvn/version \"0.3.1\"}}}}}\n```\n\n#### Via Leiningen \n\nAdd the following to your project.clj file (potentially in a development profile):\n\n```clojure\n  :dependencies \n  [... ;; you probably have other dependencies \n   [vvvvalvalval/scope-capture-nrepl \"0.3.1\"]]\n  :repl-options\n  {:nrepl-middleware\n   [... ;; you may have other nREPL middleware \n    sc.nrepl.middleware/wrap-letsc]}\n```\n\n## Usage\n\nAssume you placed a `sc.api/spy` (or `sc.api/brk`) call in the following code:\n\n```clojure \n(defn foo\n  [x y]\n  (let [z (* x y)]\n    (sc.api/spy  \n      (+ (* x x) (* 2 z) (* y y)))))\n;SPY \u003c-3\u003e /home/me/myapp/src/myapp/myns.clj:4 \n;  At Code Site -3, will save scope with locals [x y z]\n```\n\nYou ran it and got an Execution Point with id `7`:\n\n```clojure \n(foo 2 23)\n;SPY [7 -3] /home/me/myapp/src/myapp/myns.clj:4 \n;  At Execution Point 7 of Code Site -3, saved scope with locals [x y z]\n;SPY [7 -3] /home/me/myapp/src/myapp/myns.clj:4 \n;(+ (* x x) (* 2 z) (* y y))\n;=\u003e\n;625\n```\n\nYou can now 'place yourself' in the context of that Execution Point by calling `sc.nrepl.repl/in-ep`\n\n```clojure\n(sc.nrepl.repl/in-ep 7)\n```\n\nOnce you've done that, you'll see that the locals bindings of the Execution Point are always in scope, although not via Global Vars:\n\n```clojure\nx \n=\u003e 2 \n\ny \n=\u003e 23\n\nz\n=\u003e 26\n\n(+ x z)\n=\u003e 28\n```\n\nThis is achieved by wrapping each code expression to evaluate (via the 'eval' and 'load-file' nREPL ops) with `(sc.api/letsc \u003c\u003cep-id\u003e\u003e \u003c\u003cexpr\u003e\u003e)`.\n\nSo the semantics are exactly those of `sc.api/letsc`, you just don't get the tedium of writing them manually.\n\nOnce you're done with that Execution Point, you put your REPL back in a normal state by using `sc.nrepl.repl/exit`:\n\n```clojure\n(sc.nrepl.repl/exit)\n```\n\n## License\n\nCopyright © 2017 Valentin Waeselynck and contributors.\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvvvalvalval%2Fscope-capture-nrepl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvvvalvalval%2Fscope-capture-nrepl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvvvalvalval%2Fscope-capture-nrepl/lists"}