Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “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? Sign in to your account

Send multiline string #31

Open
linktohack opened this issue Nov 16, 2022 · 6 comments
Open

Send multiline string #31

linktohack opened this issue Nov 16, 2022 · 6 comments

Comments

@linktohack
Copy link
Contributor

Node has special key for multiline string. .editor. The patch bellow will allow you to evaluate all or partial of this code for example

[1, 2, 3]
  .map((it) => it + 1)
  .filter((it) => it > 0)
  .reduce((prev, curr) => prev + curr, 0);
  (el-patch-feature js-comint)

  (with-eval-after-load 'js-comint
    (el-patch-defun js-comint-send-string (str)
      "Send STR to repl."
      (el-patch-swap
	(comint-send-string (js-comint-get-process)
			    (concat str "\n"))
	(let ((lines (string-lines str)))
	  (if (length= lines 1)
	      (comint-send-string (js-comint-get-process)
				  (concat str "\n"))
	    (comint-send-string (js-comint-get-process)
				(concat ".editor" "\n" str "\n"))
	    (process-send-eof (js-comint-get-process)))))))
@redguardtoo
Copy link
Owner

Thanks. Could you send me a pull request?

@linktohack
Copy link
Contributor Author

Sure, will do

@SequentialDesign
Copy link

How can I use .editor to evaluate your example when I'm using js-comint?

@SequentialDesign
Copy link

Hmm, the above didn't work for me, but this did:

[1, 2, 3].
map((it) => it + 1).
filter((it) => it > 0).
reduce((prev, curr) => prev + curr, 0);

@linktohack
Copy link
Contributor Author

@SequentialDesign you should try the version here https://github.com/redguardtoo/js-comint/pull/33/files if you're on a version newer than 27.x.

The last PR breaks for me, too #33

@saffroy
Copy link
Contributor

saffroy commented Nov 9, 2023

After a quick test, I think (I hope!) this should work again with #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants