jasongilman / proto-repl

A Clojure Development Environment package for the Atom editor
https://atom.io/packages/proto-repl
MIT License
565 stars 50 forks source link

Add support for sending code in comments to the REPL #293

Closed sashton closed 6 years ago

sashton commented 6 years ago

This allows direct children of top-level (comment ) expressions to be run in the REPL (a common practice in other editors).

This allows test/exploratory code to remain commented out, but be easily runnable in the REPL. This is especially important when namespaces get reloaded.

Examples, where | indicates where the cursor is when the proto-repl:execute-top-block command is executed:

(comment 
  ;; this will be printed
  (println | "a"))
(comment 
  (comment
     ;; this will NOT be printed, because the direct child of the first comment is itself a comment
    (println | "a")))
(do 
  (comment 
    ;; this will NOT be printed, because the comment is not a top-level element
    (println | "a")))
(comment 
  ;; this will be printed
  (println | "a")
  ;; these will not be printed because they are separate, direct children of 'comment'
  (println "b")
  (println "c"))
jasongilman commented 6 years ago

Nice job on this one. The change works as expected.