Skip to content

Commit ba87e3c

Browse files
committed
Clean up more JS references.
1 parent 3070f73 commit ba87e3c

File tree

2 files changed

+46
-60
lines changed

2 files changed

+46
-60
lines changed

README.org

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* ts-comint.el (v0.0.5)
1+
* ts-comint.el (v0.0.1)
22
Run a TypeScript interpreter in an inferior process window
33

44
This repo is directly forked from
@@ -36,9 +36,9 @@ Insert below code to "~/.emacs.d/init.el",
3636
#+END_SRC
3737

3838
* Usage
39-
After installation, do `M-x run-ts` to create a comint buffer with the JavaScript interpreter.
39+
After installation, do `M-x run-ts` to create a comint buffer with the Typescript interpreter.
4040

41-
You can add the following couple of lines to your .emacs to take advantage of cool key bindings for sending things to the javascript interpreter inside of Steve Yegge's most excellent js2-mode.
41+
You can add the following couple of lines to your .emacs to take advantage of cool key bindings for sending things to the Typescript interpreter inside of Steve Yegge's most excellent js2-mode.
4242

4343
#+BEGIN_SRC elisp
4444
(add-hook 'typescript-mode-hook

ts-comint.el

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
;;; Copyright (C) 2008 Paul Huff
44
;;; Copyright (C) 2015 Stefano Mazzucco
5+
;;; Copyright (C) 2016 Jostein Kjønigsen
56

67
;;; Author: Paul Huff <paul.huff@gmail.com>, Stefano Mazzucco <MY FIRST NAME - AT - CURSO - DOT - RE>
7-
;;; Maintainer: Chen Bin <chenbin.sh AT gmail DOT com>
8-
;;; Created: 15 Feb 2014
9-
;;; Version: 0.0.5
8+
;;; Created: 28 September 2016
9+
;;; Version: 0.0.1
1010
;;; URL: https://github.com/josteink/ts-comint
1111
;;; Package-Requires: ()
1212
;;; Keywords: javascript, node, inferior-mode, convenience
@@ -37,8 +37,8 @@
3737
;;; Commentary:
3838

3939
;; ts-comint.el is a comint mode for Emacs which allows you to run a
40-
;; compatible javascript repl like Node.js/Spidermonkey/Rhino inside Emacs.
41-
;; It also defines a few functions for sending javascript input to it
40+
;; compatible typescript repl like Tsun inside Emacs.
41+
;; It also defines a few functions for sending typescript input to it
4242
;; quickly.
4343

4444
;; Usage:
@@ -48,19 +48,11 @@
4848
;; Do: `M-x run-ts'
4949
;; Away you go.
5050

51-
;; If you have nvm, you can select the versions of node.js installed and run
52-
;; them. This is done thanks to nvm.el.
53-
;; Please note nvm.el is optional. So you need *manually* install it.
54-
;; To enable nvm support, run `ts-do-use-nvm'.
55-
;; The first time you start the JS interpreter with run-ts, you will be asked
56-
;; to select a version of node.js
57-
;; If you want to change version of node js, run `ts-select-node-version'
58-
5951
;; You can add the following couple of lines to your .emacs to take advantage of
6052
;; cool keybindings for sending things to the javascript interpreter inside
6153
;; of Steve Yegge's most excellent js2-mode.
6254
;;
63-
;; (add-hook 'js2-mode-hook
55+
;; (add-hook 'typescript-mode-hook
6456
;; (lambda ()
6557
;; (local-set-key (kbd "C-x C-e") 'ts-send-last-sexp)
6658
;; (local-set-key (kbd "C-M-x") 'ts-send-last-sexp-and-go)
@@ -81,35 +73,26 @@
8173
:group 'inferior-ts)
8274

8375
(defcustom inferior-ts-program-arguments nil
84-
"List of command line arguments to pass to the JavaScript interpreter."
76+
"List of command line arguments to pass to the Typescript interpreter."
8577
:group 'inferior-ts)
8678

8779
(defcustom inferior-ts-mode-hook nil
8880
"*Hook for customizing inferior-ts mode."
8981
:type 'hook
9082
:group 'inferior-ts)
9183

84+
(defcustom inferior-ts-mode-ansi-color t
85+
"Use ansi-colors for inferior Typescript mode."
86+
:group 'inferior-ts)
9287

9388
(defvar inferior-ts-buffer nil
94-
"Name of the inferior JavaScript buffer.")
89+
"Name of the inferior Typescript buffer.")
9590

9691
(defvar ts-prompt-regexp "^\\(?:> \\)"
9792
"Prompt for `run-ts'.")
9893

9994

100-
(defun ts-list-nvm-versions (prompt)
101-
"List all available node versions from nvm prompting the user with PROMPT.
102-
Return a string representing the node version."
103-
(let ((candidates (sort (mapcar 'car (nvm--installed-versions)) 'string<)))
104-
(completing-read prompt
105-
candidates nil t nil
106-
nil
107-
(car candidates))))
10895
;;;###autoload
109-
(defun ts-do-use-nvm ()
110-
"Enable nvm."
111-
(setq ts-use-nvm t))
112-
11396
(defun ts--is-nodejs ()
11497
(string= "node"
11598
(substring-no-properties inferior-ts-program-command -4 nil)))
@@ -123,8 +106,8 @@ Return a string representing the node version."
123106

124107
;;;###autoload
125108
(defun run-ts (cmd &optional dont-switch-p)
126-
"Run an inferior Javascript process, input and output via buffer `*js*'.
127-
If there is a process already running in `*js*', switch to that buffer.
109+
"Run an inferior Typescript process, input and output via buffer `*ts*'.
110+
If there is a process already running in `*ts*', switch to that buffer.
128111
With argument, allows you to edit the command line (default is value
129112
of `inferior-ts-program-command').
130113
Runs the hook `inferior-ts-mode-hook' \(after the `comint-mode-hook'
@@ -144,26 +127,41 @@ is run).
144127
(setq inferior-ts-program-arguments (split-string cmd))
145128
(setq inferior-ts-program-command (pop inferior-ts-program-arguments)))))
146129

147-
(if (not (comint-check-proc "*js*"))
130+
(if (not (comint-check-proc "*ts*"))
148131
(with-current-buffer
149-
(apply 'make-comint "js" inferior-ts-program-command
132+
(apply 'make-comint "ts" inferior-ts-program-command
150133
nil inferior-ts-program-arguments)
151134
(inferior-ts-mode)))
152-
(setq inferior-ts-buffer "*js*")
135+
(setq inferior-ts-buffer "*ts*")
153136
(if (not dont-switch-p)
154-
(pop-to-buffer "*js*")))
137+
(pop-to-buffer "*ts*"))
138+
139+
;; apply terminal preferences
140+
(if inferior-ts-mode-ansi-color
141+
(progn
142+
;; based on
143+
;; http://stackoverflow.com/questions/13862471/using-node-ts-with-ts-comint-in-emacs
144+
145+
;; We like nice colors
146+
(ansi-color-for-comint-mode-on)
147+
;; Deal with some prompt nonsense
148+
(add-to-list
149+
'comint-preoutput-filter-functions
150+
(lambda (output)
151+
(replace-regexp-in-string "\033\\[[0-9]+[GKJ]" "" output))))
152+
(setenv "NODE_NO_READLINE" "1")))
155153

156154
;;;###autoload
157155
(defun ts-send-region (start end)
158-
"Send the current region to the inferior Javascript process."
156+
"Send the current region to the inferior Typescript process."
159157
(interactive "r")
160158
(run-ts inferior-ts-program-command t)
161159
(comint-send-region inferior-ts-buffer start end)
162160
(comint-send-string inferior-ts-buffer "\n"))
163161

164162
;;;###autoload
165163
(defun ts-send-region-and-go (start end)
166-
"Send the current region to the inferior Javascript process."
164+
"Send the current region to the inferior Typescript process."
167165
(interactive "r")
168166
(run-ts inferior-ts-program-command t)
169167
(comint-send-region inferior-ts-buffer start end)
@@ -172,7 +170,7 @@ is run).
172170

173171
;;;###autoload
174172
(defun ts-send-last-sexp-and-go ()
175-
"Send the previous sexp to the inferior Js process."
173+
"Send the previous sexp to the inferior Typescript process."
176174
(interactive)
177175
(ts-send-region-and-go
178176
(save-excursion
@@ -183,7 +181,7 @@ is run).
183181

184182
;;;###autoload
185183
(defun ts-send-last-sexp ()
186-
"Send the previous sexp to the inferior Javascript process."
184+
"Send the previous sexp to the inferior Typescript process."
187185
(interactive)
188186
(ts-send-region
189187
(save-excursion
@@ -194,14 +192,14 @@ is run).
194192

195193
;;;###autoload
196194
(defun ts-send-buffer ()
197-
"Send the buffer to the inferior Javascript process."
195+
"Send the buffer to the inferior Typescript process."
198196
(interactive)
199197
(ts-send-region (point-min) (point-max)))
200198

201199

202200
;;;###autoload
203201
(defun ts-send-buffer-and-go ()
204-
"Send the buffer to the inferior Javascript process."
202+
"Send the buffer to the inferior Typescript process."
205203
(interactive)
206204
(ts-send-region-and-go (point-min) (point-max)))
207205

@@ -241,7 +239,7 @@ With argument, position cursor at end of buffer."
241239
m))
242240

243241
;;;###autoload
244-
(define-derived-mode inferior-ts-mode comint-mode "Inferior Javascript"
242+
(define-derived-mode inferior-ts-mode comint-mode "Inferior Typescript"
245243
"Major mode for interacting with an inferior javascript process.
246244
247245
The following commands are available:
@@ -252,25 +250,13 @@ A typescript process can be fired up with M-x run-ts.
252250
Customization: Entry to this mode runs the hooks on comint-mode-hook and
253251
inferior-ts-mode-hook (in that order).
254252
255-
You can send text to the inferior Javascript process from other buffers containing
256-
Javascript source.
257-
switch-to-js switches the current buffer to the Javascript process buffer.
258-
ts-send-region sends the current region to the Javascript process.
253+
You can send text to the inferior Typescript process from other buffers containing
254+
Typescript source.
255+
switch-to-js switches the current buffer to the Typescript process buffer.
256+
ts-send-region sends the current region to the Typescript process.
259257
"
260258
:group 'inferior-ts
261259
(use-local-map inferior-ts-mode-map))
262260

263-
;; based on
264-
;; http://stackoverflow.com/questions/13862471/using-node-ts-with-ts-comint-in-emacs
265-
(setq inferior-ts-mode-hook
266-
(lambda ()
267-
;; We like nice colors
268-
(ansi-color-for-comint-mode-on)
269-
;; Deal with some prompt nonsense
270-
(add-to-list
271-
'comint-preoutput-filter-functions
272-
(lambda (output)
273-
(replace-regexp-in-string "\033\\[[0-9]+[GKJ]" "" output)))))
274-
275261
(provide 'ts-comint)
276262
;;; ts-comint.el ends here

0 commit comments

Comments
 (0)