@@ -8,51 +8,59 @@ Description
8
8
9
9
This program is derived from comint-mode and provides the following features.
10
10
11
- * token completion, same as Node.js REPL
12
- * file name completion in string
13
- * incremental history search
14
- * sending JavaScript codes to REPL
11
+ * token completion, same as Node.js REPL
12
+ * file name completion in string
13
+ * incremental history search
14
+ * sending JavaScript codes to REPL
15
15
16
16
Usage
17
17
-----
18
18
19
19
Put this file in your Emacs lisp path (e.g. ~ /.emacs.d/site-lisp)
20
20
and add the following line to your .emacs:
21
21
22
- (require 'nodejs-repl)
22
+ ``` elisp
23
+ (require 'nodejs-repl)
24
+ ```
23
25
24
26
Type ` M-x nodejs-repl ` to run Node.js REPL.
25
27
See also ` comint-mode ` to check key bindings.
26
28
27
29
You can define key bindings to send JavaScript codes to REPL like below:
28
30
29
- (add-hook 'js-mode-hook
30
- (lambda ()
31
- (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)
33
- (define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region)
34
- (define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file)
35
- (define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl)))
31
+ ``` elisp
32
+ (add-hook 'js-mode-hook
33
+ (lambda ()
34
+ (define-key js-mode-map (kbd "C-x C-e") 'nodejs-repl-send-last-expression)
35
+ (define-key js-mode-map (kbd "C-c C-j") 'nodejs-repl-send-line)
36
+ (define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region)
37
+ (define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file)
38
+ (define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl)))
39
+ ```
36
40
37
41
When a version manager such as nvm is used to run different versions
38
42
of Node.js, it is often desirable to start the REPL of the version
39
43
specified in the .nvmrc file per project. In such case, customize the
40
44
` nodejs-repl-command ` variable with a function symbol. That function
41
45
should query nvm for the Node.js command to run. For example:
42
46
43
- (require 'nodejs-repl)
44
- (defun nvm-which ()
45
- (let* ((shell (concat (getenv "SHELL") " -l -c 'nvm which'"))
46
- (output (shell-command-to-string shell)))
47
- (cadr (split-string output "[\n]+" t))))
48
- (setq nodejs-repl-command #'nvm-which)
47
+ ``` elisp
48
+ (require 'nodejs-repl)
49
+ (defun nvm-which ()
50
+ (let* ((shell (concat (getenv "SHELL") " -l -c 'nvm which'"))
51
+ (output (shell-command-to-string shell)))
52
+ (cadr (split-string output "[\n]+" t))))
53
+ (setq nodejs-repl-command #'nvm-which)
54
+ ```
49
55
50
56
The ` nvm-which ` function can be simpler, and perhaps can run faster,
51
57
too, if using Bash:
52
58
53
- (defun nvm-which ()
54
- (let ((output (shell-command-to-string "source ~/.nvm/nvm.sh; nvm which")))
55
- (cadr (split-string output "[\n]+" t))))
59
+ ``` elisp
60
+ (defun nvm-which ()
61
+ (let ((output (shell-command-to-string "source ~/.nvm/nvm.sh; nvm which")))
62
+ (cadr (split-string output "[\n]+" t))))
63
+ ```
56
64
57
65
Author
58
66
------
@@ -63,7 +71,7 @@ Takeshi Arabiki (abicky)
63
71
Copyright and License
64
72
---------------------
65
73
66
- Copyright (C) 2012-2017 Takeshi Arabiki (abicky)
74
+ Copyright (C) 2012-2018 Takeshi Arabiki (abicky)
67
75
68
76
This program is free software: you can redistribute it and/or modify
69
77
it under the terms of the GNU General Public License as published by
0 commit comments