Emacs nodejs-repl sending data to buffer

591 Views Asked by At

nodejs-repl command starts a *nodejs* commit-buffer. How to send the contents of a javascript buffer to the *nodejs* buffer using a key binding. Is there a command in commint-mode which does that.

1

There are 1 best solutions below

0
On

i thought i had send-to-node-repl bound to a key by default just a few days ago, but today it was gone. maybe i gave up searching too soon, but writing this seemed quicker:

(defun send-region-to-nodejs-repl-process (start end)
  "Send region to `nodejs-repl' process."
  (interactive "r")
  (save-selected-window
    (save-excursion (nodejs-repl)))
  (comint-send-region (get-process nodejs-repl-process-name)
                      start end))

(define-key js3-mode-map (kbd "C-c C-r") 'send-region-to-nodejs-repl-process)

replace js3-mode-map with some other keymap if that isn't where you want it available.