-
-
Notifications
You must be signed in to change notification settings - Fork 44
Handle newlines between forms for inf-clojure-eval-buffer
#188
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Conversation
inf-clojure.el
Outdated
;; newlines over a socket repl between top level forms cause | ||
;; a prompt to be returned. so here we dump the region into a | ||
;; temp buffer, and delete all newlines between the forms | ||
(formatted (condition-case nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's seems a bit too complicated to me. Can't we just use the built-in delete-blank-lines
or something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I see you tried to kill the blank lines only between top-level forms. That seems reasonable, but we should probably move this to some helper function, so it's clearer what it does (and we can add a test or two about it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do tonight thanks!
@bbatsov the change is pretty big but look at the last commit. There were a bunch of poorly formatted tests so i just knocked those out. |
This sends the contents of the buffer. However, newlines cause the prompt to be returned. You can see this with even a regular clojure repl: ```bash ❯❯❯ clojure Clojure 1.10.2 user=> user=> user=> ``` (note using `clj` has rlwrap which hides a bit of this so make sure to use `clojure`). But what we can do is make sure to transform ```clojure (defn foo [] ...) (defn bar [] ...) ``` into ```clojure (defn foo [] ...) (defn bar [] ...) ``` So that the newlines don't trigger more repl prompts. Real world usage below: Before: ```clojure parse=> nil parse=> parse=> nil parse=> parse=> #'parse/data parse=> parse=> #'parse/parse-where parse=> parse=> #'parse/keywords parse=> parse=> #'parse/tokenize parse=> parse=> #'parse/parse parse=> parse=> #'parse/translate-where parse=> parse=> nil parse=> parse=> #'parse/query parse=> parse=> #'parse/query-test parse=> parse=> #'parse/bonus-points-test parse=> ``` After: ```clojure user=> nil parse=> nil parse=> #'parse/data parse=> #'parse/parse-where parse=> #'parse/keywords parse=> parse=> #'parse/parse parse=> #'parse/translate-where parse=> nil parse=> #'parse/query parse=> #'parse/query-test parse=> #'parse/bonus-points-test parse=> ```
Looks good. Thanks! |
This sends the contents of the buffer. However, newlines cause the
prompt to be returned. You can see this with even a regular clojure
repl:
(note using
clj
has rlwrap which hides a bit of this so make sure touse
clojure
).But what we can do is make sure to transform
into
So that the newlines don't trigger more repl prompts. Real world usage below:
Before:
After: