Skip to content

Commit

Permalink
3.7.1 Added expand argument to clojure_sublimed_eval command
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Mar 15, 2024
1 parent 4b861c3 commit 5104efb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.7.1 - Mar 15, 2024

- Added `expand` argument to `clojure_sublimed_eval` command

### 3.7.0 - Mar 14, 2024

- New feature: Watches! Added `Add Watch` command
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ If you now press `ctrl+p` on a form like `(+ 1 2)`, the actual eval sent to REPL

Which will pretty-print evaluation result to stdout. This pattern might be useful for large results that don’t fit inline.

We can implement macroexpand this way:

```
{"keys": ["ctrl+e"],
"command": "clojure_sublimed_eval",
"args": {"transform": "(macroexpand-1 '%code)",
"expand": true}}
```

Another use-case might be “eval to buffer”:

```
Expand Down
14 changes: 10 additions & 4 deletions cs_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,18 @@ class ClojureSublimedEvalCommand(sublime_plugin.TextCommand):
"""
Eval selected code or topmost form is selection is collapsed
"""
def run(self, edit, print_quota = None, transform = None):
def run(self, edit, print_quota = None, transform = None, expand = False):
state = cs_common.get_state(self.view.window())

transform_fn = None
if transform:
state.conn.eval(self.view, self.view.sel(), format_code_fn(transform), print_quota = print_quota)
else:
state.conn.eval(self.view, self.view.sel(), print_quota = print_quota)
transform_fn = format_code_fn(transform)

on_finish = None
if expand:
on_finish = lambda _: self.view.run_command("clojure_sublimed_toggle_info", {})

state.conn.eval(self.view, self.view.sel(), transform_fn = transform_fn, print_quota = print_quota, on_finish = on_finish)

def is_enabled(self):
return cs_conn.ready(self.view.window())
Expand Down

0 comments on commit 5104efb

Please sign in to comment.