abicky / nodejs-repl.el

Run Node.js REPL and communicate with the process
190 stars 38 forks source link

Error in process filter #37

Closed leafarbelm closed 7 months ago

leafarbelm commented 4 years ago

Emacs version: 27.1 nodejs-repl version: 0.2.4 Node version: 14.10.1

Steps to reproduce:

  1. Open any .js file
  2. Execute M-x nodejs-repl
  3. digit any expression on the repl (e.g. 5 + 8)

I installed this mode and when i execute any expression in the REPL buffer i get the following errors:

error in process filter: run-hook-with-args: End of buffer error in process filter: End of buffer

and the RELP hang up a little bit, i don't now much about elisp so i was wondering if someone could help me with this?

This is the config i use, nothing especial:

(use-package nodejs-repl
  :config
  (add-hook 'js-mode-hook
          (lambda ()
            (define-key js-mode-map (kbd "C-x C-e") 'nodejs-repl-send-last-expression)
            (define-key js-mode-map (kbd "C-c C-j") 'nodejs-repl-send-line)
            (define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region)
            (define-key js-mode-map (kbd "C-c C-c") 'nodejs-repl-send-buffer)
            (define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file)
            (define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl))))
zodmaner commented 3 years ago

I've also encountered this problem on Emacs 26.3 with nodejs-repl versions 0.2.4 and 0.2.3 and Node versions v14.12.0 and v12.18.4.

digitables commented 3 years ago

Hi, I've also had this problem with Node v16.9.1, nodejs-repl version 0.2.4, and emacs version 27.1

digitables commented 3 years ago

Found a fix on floscr's emacs config! IIRC map! is a Doom Emacs thing so it might not work on vanilla or spacemacs. https://github.com/floscr/emacs.d/blob/master/config.org The specific thing I did was add the following snipped to the end of ~/.doom.d/config.el:

(map!
 :after comint
 :map comint-mode-map
 :ni "RET" (cmd! (comint-send-input nil t))
 :n "<C-backspace>" #'comint-clear-buffer)
dop commented 2 years ago

I think I have a workaround. It seems that culprit is nodejs-repl--delete-prompt in comint-output-filter-functions.

(defun dp/nodejs-repl-remove-broken-filter ()
  (remove-hook 'comint-output-filter-functions 'nodejs-repl--delete-prompt t))
(add-hook 'nodejs-repl-mode-hook #'dp/nodejs-repl-remove-broken-filter)

This results in duplicated prompt from time to time. But it's better than freezing.

dfpetrin commented 2 years ago

Found a fix on floscr's emacs config! IIRC map! is a Doom Emacs thing so it might not work on vanilla or spacemacs. https://github.com/floscr/emacs.d/blob/master/config.org The specific thing I did was add the following snipped to the end of ~/.doom.d/config.el:

(map!
 :after comint
 :map comint-mode-map
 :ni "RET" (cmd! (comint-send-input nil t))
 :n "<C-backspace>" #'comint-clear-buffer)

Unfortunately this leads to echoing back the input, which is annoying.

I think I have a workaround. It seems that culprit is nodejs-repl--delete-prompt in comint-output-filter-functions.

(defun dp/nodejs-repl-remove-broken-filter ()
  (remove-hook 'comint-output-filter-functions 'nodejs-repl--delete-prompt t))
(add-hook 'nodejs-repl-mode-hook #'dp/nodejs-repl-remove-broken-filter)

This results in duplicated prompt from time to time. But it's better than freezing.

This seems to be working for me so far!

abicky commented 7 months ago

I've released nodejs-repl.el 0.2.5 that has resolved the bug, so I'll close this issue.