abicky / nodejs-repl.el

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

command to restart the REPL without killing the buffer #23

Closed boehm-s closed 5 years ago

boehm-s commented 5 years ago

A while ago, I answered this question, and I think the command could be useful to other users.

I'm not experimented at all in elisp, so I'm open to all kind of suggestions,

Cheers

abicky commented 5 years ago

Thank you for your PR! I think it is better to introduce nodejs-repl-use-global custom variable so that .clear command clears the current context. The current implementation sets useGlobal to true as node CLI REPL does. cf. https://nodejs.org/api/repl.html#repl_repl_start_options

What do you think?

% node -e "require('repl').start({ replMode: 'magic', useGlobal: true })"
> let foo = 1;
undefined
> .clear
> let foo = 2;
TypeError: Identifier 'foo' has already been declared
> 
% node -e "require('repl').start({ replMode: 'magic', useGlobal: false })"
> let foo = 1;
undefined
> .clear
Clearing context...
> let foo = 2;
undefined
boehm-s commented 5 years ago

I haven't tought about that, it's way better, and cleaner for sure !

boehm-s commented 5 years ago

Do you think it's OK like that ?

abicky commented 5 years ago

I've published 0.2.1.