Skip to content

Commit 8148298

Browse files
lycheesebbatsov
authored andcommitted
Add docs for evaluating in comments
Document clojure-toplevel-inside-comment-form for changing the behaviour of defun-style commands.
1 parent df34f14 commit 8148298

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

doc/modules/ROOT/pages/usage/code_evaluation.adoc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,44 @@ You can also use the command `cider-kill-last-result`(kbd:[C-c C-v k]) after any
302302
eval command to store its result in the kill ring. This works even when the
303303
`cider-eval-register` feature is disabled.
304304

305+
=== Evaluating inside comments
306+
307+
By default, when using the defun-style eval commands inside a comment the return value is always `nil`. Calling `cider-eval-defun-up-to-point` with point at `<point>` also returns `nil`:
308+
309+
[source,clojure]
310+
----
311+
(comment
312+
(let [b "str"]
313+
(-> b
314+
keyword<point> ;;=> nil
315+
name))
316+
*e)
317+
----
318+
319+
However, as it is often desirable to treat the form the point is in as if was not inside a comment, `clojure-mode` supplies the variable `clojure-toplevel-inside-comment-form`. If this variable is set to `t` then instead of `nil` we get:
320+
321+
[source,clojure]
322+
----
323+
(comment
324+
(let [b "str"]
325+
(-> b
326+
keyword<point> ;;=> :str
327+
name))
328+
*e)
329+
----
330+
331+
With `cider-eval-defun-at-point` we get:
332+
333+
[source,clojure]
334+
----
335+
(comment
336+
(let [b "str"]
337+
(-> b
338+
keyword<point>
339+
name));;=> "str"
340+
*e)
341+
----
342+
305343

306344
== Keybindings
307345

0 commit comments

Comments
 (0)