@@ -164,6 +164,37 @@ default to the current buffer's directory."
164
164
map)
165
165
" Basic mode map for `psci' ." )
166
166
167
+ (defun psci-completion-preoutput-filter (string )
168
+ (setq psci-completion-captured-output (concat psci-completion-captured-output string))
169
+ " " )
170
+
171
+ (defun psci-tidy-completion-output (response )
172
+ (let* ((response-lines (split-string response " \n " t nil ))
173
+ (response-lines-without-prompt (nbutlast response-lines)))
174
+ response-lines-without-prompt))
175
+
176
+
177
+ (defun psci-tab-completion ()
178
+ (let* ((line (thing-at-point 'line t ))
179
+ (command (format " :complete %s " line)))
180
+ (-when-let (process (get-buffer-process (psci--process-name psci/buffer-name)))
181
+ (add-hook 'comint-preoutput-filter-functions 'psci-completion-preoutput-filter nil t )
182
+ (comint-simple-send process command)
183
+ (accept-process-output process)
184
+ (remove-hook 'comint-preoutput-filter-functions 'psci-completion-preoutput-filter t )
185
+ (let ((response psci-completion-captured-output))
186
+ (setq psci-completion-captured-output " " )
187
+ (when (not (string-prefix-p " Unrecognized directive." response))
188
+ (save-excursion
189
+ (let* ((end (point ))
190
+ (start (+ (re-search-backward comint-prompt-regexp)
191
+ (length psci/prompt)))
192
+ (results (psci-tidy-completion-output response)))
193
+ (list start end results))))))))
194
+
195
+ (defvar psci-dynamic-complete-functions
196
+ '(psci-tab-completion))
197
+
167
198
;;;### autoload
168
199
(define-derived-mode psci-mode comint-mode " psci"
169
200
" Major mode for `run-psci' .
@@ -181,7 +212,10 @@ default to the current buffer's directory."
181
212
(setq-local comint-input-filter-functions nil )
182
213
(setq-local font-lock-defaults '(purescript-font-lock-keywords t ))
183
214
(setq-local comment-start " -- " )
184
- (setq-local comment-use-syntax t ))
215
+ (setq-local comment-use-syntax t )
216
+ (setq-local comment-use-syntax t )
217
+ (setq-local comint-dynamic-complete-functions psci-dynamic-complete-functions)
218
+ (setq-local psci-completion-captured-output " " ))
185
219
186
220
;;;### autoload
187
221
(defun psci/load-current-file! ()
@@ -202,7 +236,7 @@ default to the current buffer's directory."
202
236
(defun psci/reset! ()
203
237
" Reset the current status of the repl session."
204
238
(interactive )
205
- (psci--run-psci-command! " :reset " ))
239
+ (psci--run-psci-command! " :clear " ))
206
240
207
241
;;;### autoload
208
242
(defun psci/quit! ()
0 commit comments