|
3 | 3 | ;; Copyright (C) 2012-2020 Takeshi Arabiki |
4 | 4 |
|
5 | 5 | ;; Author: Takeshi Arabiki |
6 | | -;; Version: 0.2.3 |
| 6 | +;; Version: 0.2.4 |
7 | 7 |
|
8 | 8 | ;; This program is free software: you can redistribute it and/or modify |
9 | 9 | ;; it under the terms of the GNU General Public License as published by |
|
22 | 22 | ;; |
23 | 23 | ;; This program is derived from comint-mode and provides the following features. |
24 | 24 | ;; |
25 | | -;; * TAB completion same as Node.js REPL |
| 25 | +;; * token completion, same as Node.js REPL |
26 | 26 | ;; * file name completion in string |
27 | 27 | ;; * incremental history search |
| 28 | +;; * sending JavaScript codes to REPL |
28 | 29 | ;; |
29 | 30 | ;; |
30 | 31 | ;; Put this file in your Emacs lisp path (e.g. ~/.emacs.d/site-lisp) |
|
40 | 41 | ;; (add-hook 'js-mode-hook |
41 | 42 | ;; (lambda () |
42 | 43 | ;; (define-key js-mode-map (kbd "C-x C-e") 'nodejs-repl-send-last-expression) |
| 44 | +;; (define-key js-mode-map (kbd "C-c C-j") 'nodejs-repl-send-line) |
43 | 45 | ;; (define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region) |
44 | 46 | ;; (define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file) |
45 | 47 | ;; (define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl))) |
|
73 | 75 | "Run Node.js REPL and communicate the process." |
74 | 76 | :group 'processes) |
75 | 77 |
|
76 | | -(defconst nodejs-repl-version "0.2.3" |
| 78 | +(defconst nodejs-repl-version "0.2.4" |
77 | 79 | "Node.js mode Version.") |
78 | 80 |
|
79 | 81 | (defcustom nodejs-repl-command "node" |
@@ -223,7 +225,7 @@ See also `comint-process-echoes'" |
223 | 225 | (not |
224 | 226 | (let ((last-line (process-get proc 'last-line))) |
225 | 227 | (or (string-match-p nodejs-repl-prompt-re last-line) |
226 | | - (string= last-line string))))) |
| 228 | + (string-prefix-p string last-line))))) |
227 | 229 | (process-put proc 'running-p nil) |
228 | 230 | (accept-process-output proc interval))) |
229 | 231 |
|
@@ -308,7 +310,9 @@ when receive the output string" |
308 | 310 |
|
309 | 311 | (defun nodejs-repl--delete-prompt (string) |
310 | 312 | ;; Redundant prompts are included in outputs from Node.js REPL |
311 | | - (when nodejs-repl-prompt-deletion-required-p |
| 313 | + (when (and nodejs-repl-prompt-deletion-required-p |
| 314 | + ;; To avoid end-of-buffer error at the line of (forward-char (length nodejs-repl-prompt)) |
| 315 | + (> (buffer-size) 0)) |
312 | 316 | (setq nodejs-repl-prompt-deletion-required-p nil) |
313 | 317 | (let ((beg (or comint-last-output-start |
314 | 318 | (point-min-marker))) |
@@ -455,9 +459,7 @@ when receive the output string" |
455 | 459 | ;; See: https://github.com/abicky/nodejs-repl.el/issues/17 |
456 | 460 | (comint-send-string proc ".editor\n") |
457 | 461 | (comint-send-region proc start end) |
458 | | - (comint-send-string proc "\n") |
459 | | - (with-current-buffer (process-buffer proc) |
460 | | - (comint-send-eof)))) |
| 462 | + (comint-send-string proc "\n\x04"))) |
461 | 463 |
|
462 | 464 | ;;;###autoload |
463 | 465 | (defun nodejs-repl-send-buffer () |
|
0 commit comments