inf-clojure

GitHub: https://github.com/clojure-emacs/inf-clojure Discord (official chat): https://discord.gg/nFPpynQPME
2021-04-05T01:58:06.019Z

Hey. The inf-clojure repl is getting an extra prompt for each newline present in the evaluated form. For example, if I evaluate a form with 5 lines, the repl looks like this:

my.project=>               #_=>               #_=>               #_=>               #_=> nil
Anyone facing the same issue? I’m using inf-clojure and selecting lein repl. For some reason, this bug is not reproducible if I start a repl externally and use inf-clojure-connect .

dpsutton 2021-04-05T01:59:43.019800Z

I’ve been using socket repls exclusively. I haven’t tested on a bare repl in a while

dpsutton 2021-04-05T01:59:52.020100Z

I’d suggest using the socket repl

dpsutton 2021-04-05T02:01:59.021600Z

Those look like the sub prompts. I think there was some code involved that would make everything a single string and strip new lines for this reason

2021-04-05T02:03:29.021800Z

Oh, I just realized this does not happen when I use inf-clojure-eval-last-sexp directly, rather than my own fork of lispy. My bad. (that’s weird though, as lispy will simply use inf-clojure-eval-last-sexp with call-interactivelly [1]. Anyway, will investigate). [1]: https://github.com/Andre0991/lispy-lite/blob/main/lispy.el#L4237

2021-04-05T02:04:29.022700Z

On the socket repl, I’d like to go to that route, yeap. But since it’s a lein project, I guess using lein repl is unavoidable, right?

dpsutton 2021-04-05T02:05:04.023200Z

You can add some jvm properties to get a socket repl

dpsutton 2021-04-05T02:05:34.023800Z

:jvm-opts
    ["-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl}"]

2021-04-05T02:05:54.024300Z

Oh right, I experimented with that as well. The issue is that I haven’t figured out a way of randomising the port in case I need to spin multiple repls - see https://clojurians.slack.com/archives/C9BT75KRC/p1617506171010800

dpsutton 2021-04-05T02:06:05.024800Z

yeah i think that's a pain

2021-04-05T02:06:38.025200Z

Okay 😞

2021-04-05T02:08:23.025600Z

Anyways, thanks for your help

2021-04-05T02:16:12.026400Z

Just out of curiosity: confirmed that (call-interactivelly ’inf-clojure-eval-last-sexp) inserts the extra prompts, while inf-clojure-eval-last-sexp (actually called interactivelly by me) doesn’t. That’s so weird. Maybe something is relying on this-command. Will investigate.

dpsutton 2021-04-05T02:22:58.026700Z

Very interested

dpsutton 2021-04-05T02:23:39.027900Z

And I’ll try to run non socket versions more. Also the discord server for cider is more of the official spot for development now these days

1👍
2021-04-05T02:39:07.028700Z

Oh, I didn’t know about the discord server. Cool, just joined it.

2021-04-05T02:40:08.029900Z

By the way, just confirmed that the issue is this-command , as it has a different value when call-interactivelly is called: https://github.com/clojure-emacs/inf-clojure/blob/1e99b8246bb1fe7666d613a9ae566e2a939fc2bb/inf-clojure.el#L669 Well, its usage looks legitimate here, of course. I’ll try some workaround.

2021-04-05T03:07:50.033200Z

(add-hook 'comint-preoutput-filter-functions #'inf-clojure-preoutput-filter nil t)
add-hook is already setting LOCAL to 't, so the function that was added to 'comint-preoutput-filter-functions won’t affect other comint buffers. In fact, I just opened a shell buffer, inspected comint-preoutput-filter-functions and #'inf-clojure-preoutput-filter is not there. I’ll open an issue about it, but unless I’m missing something, we can simply remove the check (string-prefix-p "inf-clojure-" (symbol-name (or this-command last-command))) :thinking_face:

2021-04-05T03:16:52.034Z

Hummm, on second thoughts, if you are interacting with the repl buffer directly, you probably don’t want those hooks to interfere with them.

2021-04-05T03:18:46.035Z

Yeah, I guess I’ll do the right thing and call the function non-interactively

bozhidar 2021-04-05T06:28:13.035300Z

Hmm, I missed that message about the future deprecation, and this was never on the table, so I guess I just didn't read carefully enough some PR. 😄

bozhidar 2021-04-05T06:29:05.035500Z

Yeah, I meant just selecting lein repl in the list - new extra prompts likely indicate the evaluation of several expressions or something along those lines.

bozhidar 2021-04-05T06:30:06.035700Z

@dpsutton might be able to share more on the topic.

bozhidar 2021-04-05T06:31:09.035900Z

(I see that according to git blame he added this to the README)

2021-04-05T06:39:33.036300Z

Well, but if the inf-clojure command is not called interactively, the comint hook won’t filter the text, as it consults last-command. So… I dunno. Thinking in other workarounds.

dpsutton 2021-04-05T13:07:32.037300Z

I probably reformatted the paragraph but that copy preceded me

dpsutton 2021-04-05T13:44:03.037500Z

That wording seems to have showed up in this commit: https://github.com/clojure-emacs/inf-clojure/commit/b53074a1eeae9e21f6f99f4d5a96bb294c7ba79a