64
64
65
65
(require 'comint )
66
66
67
- (defgroup inferior-ts nil
67
+ (defgroup ts-comint nil
68
68
" Run a Typescript process in a buffer."
69
- :group 'inferior-ts )
69
+ :group 'languages )
70
70
71
- (defcustom inferior-ts -program-command " tsun"
71
+ (defcustom ts-comint -program-command " tsun"
72
72
" Typescript interpreter."
73
- :group 'inferior-ts )
73
+ :group 'ts-comint )
74
74
75
- (defcustom inferior-ts -program-arguments nil
75
+ (defcustom ts-comint -program-arguments nil
76
76
" List of command line arguments to pass to the Typescript interpreter."
77
- :group 'inferior-ts )
77
+ :group 'ts-comint )
78
78
79
- (defcustom inferior-ts -mode-hook nil
79
+ (defcustom ts-comint -mode-hook nil
80
80
" *Hook for customizing inferior-ts mode."
81
81
:type 'hook
82
- :group 'inferior-ts )
82
+ :group 'ts-comint )
83
83
84
- (defcustom inferior-ts -mode-ansi-color t
84
+ (defcustom ts-comint -mode-ansi-color t
85
85
" Use ansi-colors for inferior Typescript mode."
86
- :group 'inferior-ts )
86
+ :group 'ts-comint )
87
87
88
- (defvar inferior-ts -buffer nil
88
+ (defvar ts-comint -buffer nil
89
89
" Name of the inferior Typescript buffer." )
90
90
91
91
(defvar ts-prompt-regexp " ^\\ (?:> \\ )"
94
94
95
95
(defun ts--is-nodejs ()
96
96
(string= " node"
97
- (substring-no-properties inferior-ts -program-command -4 nil )))
97
+ (substring-no-properties ts-comint -program-command -4 nil )))
98
98
99
99
(defun ts--guess-load-file-cmd (filename )
100
100
(let ((cmd (concat " require(\" " filename " \" )\n " )))
108
108
" Run an inferior Typescript process, input and output via buffer `*ts*' .
109
109
If there is a process already running in `*ts*' , switch to that buffer.
110
110
With argument, allows you to edit the command line (default is value
111
- of `inferior-ts -program-command' ).
112
- Runs the hook `inferior-ts -mode-hook' \( after the `comint-mode-hook'
111
+ of `ts-comint -program-command' ).
112
+ Runs the hook `ts-comint -mode-hook' \( after the `comint-mode-hook'
113
113
is run).
114
114
\( Type \\ [describe-mode] in the process buffer for a list of commands.)"
115
115
(interactive
@@ -120,23 +120,23 @@ is run).
120
120
(mapconcat
121
121
'identity
122
122
(cons
123
- inferior-ts -program-command
124
- inferior-ts -program-arguments)
123
+ ts-comint -program-command
124
+ ts-comint -program-arguments)
125
125
" " )))
126
- (setq inferior-ts -program-arguments (split-string cmd))
127
- (setq inferior- ts-program-command (pop inferior-ts -program-arguments)))))
126
+ (setq ts-comint -program-arguments (split-string cmd))
127
+ (setq ts-comint- program-command (pop ts-comint -program-arguments)))))
128
128
129
129
(if (not (comint-check-proc " *ts*" ))
130
130
(with-current-buffer
131
- (apply 'make-comint " ts" inferior-ts -program-command
132
- nil inferior-ts -program-arguments)
133
- (inferior-ts -mode)))
134
- (setq inferior-ts -buffer " *ts*" )
131
+ (apply 'make-comint " ts" ts-comint -program-command
132
+ nil ts-comint -program-arguments)
133
+ (ts-comint -mode)))
134
+ (setq ts-comint -buffer " *ts*" )
135
135
(if (not dont-switch-p)
136
136
(pop-to-buffer " *ts*" ))
137
137
138
138
; ; apply terminal preferences
139
- (if inferior-ts -mode-ansi-color
139
+ (if ts-comint -mode-ansi-color
140
140
(progn
141
141
; ; based on
142
142
; ; http://stackoverflow.com/questions/13862471/using-node-ts-with-ts-comint-in-emacs
@@ -154,18 +154,18 @@ is run).
154
154
(defun ts-send-region (start end )
155
155
" Send the current region to the inferior Typescript process."
156
156
(interactive " r" )
157
- (run-ts inferior-ts -program-command t )
158
- (comint-send-region inferior-ts -buffer start end)
159
- (comint-send-string inferior-ts -buffer " \n " ))
157
+ (run-ts ts-comint -program-command t )
158
+ (comint-send-region ts-comint -buffer start end)
159
+ (comint-send-string ts-comint -buffer " \n " ))
160
160
161
161
;;;### autoload
162
162
(defun ts-send-region-and-go (start end )
163
163
" Send the current region to the inferior Typescript process."
164
164
(interactive " r" )
165
- (run-ts inferior-ts -program-command t )
166
- (comint-send-region inferior-ts -buffer start end)
167
- ; ; (comint-send-string inferior-ts -buffer "\n")
168
- (switch-to-ts inferior-ts -buffer))
165
+ (run-ts ts-comint -program-command t )
166
+ (comint-send-region ts-comint -buffer start end)
167
+ ; ; (comint-send-string ts-comint -buffer "\n")
168
+ (switch-to-ts ts-comint -buffer))
169
169
170
170
;;;### autoload
171
171
(defun ts-send-last-sexp-and-go ()
@@ -207,55 +207,55 @@ is run).
207
207
" Load a file in the Typescript interpreter."
208
208
(interactive " f" )
209
209
(let ((filename (expand-file-name filename)))
210
- (run-ts inferior-ts -program-command t )
211
- (comint-send-string inferior-ts -buffer (ts--guess-load-file-cmd filename))))
210
+ (run-ts ts-comint -program-command t )
211
+ (comint-send-string ts-comint -buffer (ts--guess-load-file-cmd filename))))
212
212
213
213
;;;### autoload
214
214
(defun ts-load-file-and-go (filename )
215
215
" Load a file in the Typescript interpreter."
216
216
(interactive " f" )
217
217
(let ((filename (expand-file-name filename)))
218
- (run-ts inferior-ts -program-command t )
219
- (comint-send-string inferior-ts -buffer (ts--guess-load-file-cmd filename))
220
- (switch-to-ts inferior-ts -buffer)))
218
+ (run-ts ts-comint -program-command t )
219
+ (comint-send-string ts-comint -buffer (ts--guess-load-file-cmd filename))
220
+ (switch-to-ts ts-comint -buffer)))
221
221
222
222
;;;### autoload
223
223
(defun switch-to-ts (eob-p )
224
224
" Switch to the Typescript process buffer.
225
225
With argument, position cursor at end of buffer."
226
226
(interactive " P" )
227
- (if (and inferior- ts-buffer (get-buffer inferior-ts -buffer))
228
- (pop-to-buffer inferior-ts -buffer)
229
- (error " No current process buffer. See variable `inferior-ts -buffer' " ))
227
+ (if (and ts-comint- buffer (get-buffer ts-comint -buffer))
228
+ (pop-to-buffer ts-comint -buffer)
229
+ (error " No current process buffer. See variable `ts-comint -buffer' " ))
230
230
(when eob-p
231
231
(push-mark )
232
232
(goto-char (point-max ))))
233
233
234
- (defvar inferior-ts -mode-map
234
+ (defvar ts-comint -mode-map
235
235
(let ((m (make-sparse-keymap )))
236
236
(define-key m " \C -x\C -e" 'ts-send-last-sexp )
237
237
(define-key m " \C -cl" 'ts-load-file )
238
238
m))
239
239
240
240
;;;### autoload
241
- (define-derived-mode inferior-ts -mode comint-mode " Inferior Typescript"
241
+ (define-derived-mode ts-comint -mode comint-mode " Inferior Typescript"
242
242
" Major mode for interacting with an inferior Typescript process.
243
243
244
244
The following commands are available:
245
- \\ {inferior-ts -mode-map}
245
+ \\ {ts-comint -mode-map}
246
246
247
247
A typescript process can be fired up with M-x run-ts.
248
248
249
249
Customization: Entry to this mode runs the hooks on comint-mode-hook and
250
- inferior-ts -mode-hook (in that order).
250
+ ts-comint -mode-hook (in that order).
251
251
252
252
You can send text to the inferior Typescript process from other buffers containing
253
253
Typescript source.
254
254
switch-to-ts switches the current buffer to the Typescript process buffer.
255
255
ts-send-region sends the current region to the Typescript process.
256
256
"
257
257
:group 'inferior-ts
258
- (use-local-map inferior-ts -mode-map))
258
+ (use-local-map ts-comint -mode-map))
259
259
260
260
(provide 'ts-comint )
261
261
; ;; ts-comint.el ends here
0 commit comments