Skip to content

Commit 9bde0a5

Browse files
committed
Merge branch 'feature/send-line' into develop
2 parents 9138446 + ff4c710 commit 9bde0a5

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ You can define key bindings to send JavaScript codes to REPL like below:
2929
(add-hook 'js-mode-hook
3030
(lambda ()
3131
(define-key js-mode-map (kbd "C-x C-e") 'nodejs-repl-send-last-expression)
32+
(define-key js-mode-map (kbd "C-c C-j") 'nodejs-repl-send-line)
3233
(define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region)
3334
(define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file)
3435
(define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl)))

nodejs-repl.el

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,19 @@ when receive the output string"
355355
"Send ^U to Node.js process."
356356
(nodejs-repl--send-string "\x15"))
357357

358+
;;;###autoload
359+
(defun nodejs-repl-send-line ()
360+
"Send the current line to the `nodejs-repl-process'"
361+
(interactive)
362+
(save-excursion
363+
(let ((proc (nodejs-repl--get-or-create-process))
364+
(start))
365+
(beginning-of-line)
366+
(setq start (point))
367+
(end-of-line)
368+
(comint-send-region proc start (point))
369+
(comint-send-string proc "\n"))))
370+
358371
;;;###autoload
359372
(defun nodejs-repl-send-region (start end)
360373
"Send the current region to the `nodejs-repl-process'"

0 commit comments

Comments
 (0)