Skip to content

Commit 337ca30

Browse files
committed
Create ELisp function to connect to existing SEPL instances
1 parent b4e6cbb commit 337ca30

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

emacs/sepl-mode.el

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
(require 's)
22

3-
;; TODO: make a sepl-send-command-to-process or something that all eval style funcs can use
4-
53
(defun sepl-eval-sexp ()
64
(interactive)
75
(let* ((start (point))
@@ -40,17 +38,14 @@
4038
(set (make-local-variable 'sepl-repl-process)
4139
(get-buffer-process "*SEPL REPL*")))
4240

43-
;; TODO: maybe some sort of error message if we try to start two proceses? Only one allowed at the moment. To make life simpler for myself.
4441
(define-derived-mode sepl-repl-mode comint-mode
4542
"SEPL REPL"
4643
"Mode used inside the repl to the SEPL process. Dr. Seuss would be proud."
4744

48-
;; TODO: rest of the buffer should be read only, except the prompt
4945
(setq-local comint-use-prompt-regexp t
5046
comint-prompt-regexp "> "
5147
comint-prompt-read-only t)
5248

53-
;; TODO: could we activate highlight of scheme keywords?
5449
(require 'scheme)
5550
(setq-local font-lock-keywords scheme-font-lock-keywords)
5651

@@ -61,21 +56,22 @@
6156
:group 'sepl
6257
:type 'string)
6358

64-
(defun sepl-repl-start ()
59+
(defun sepl-repl-connect ()
60+
"Connects to an existing SEPL instance, and starts a REPL interface."
6561
(interactive)
66-
(let ((buffer (get-buffer-create "*SEPL REPL*"))
67-
(glsl-file (buffer-file-name (current-buffer))))
68-
(start-process "sepl" "*SEPL-STDOUT*" sepl-program-bin glsl-file)
69-
;; give process 2 seconds to start
70-
(sleep-for 2)
71-
;; TODO: open the comint buffer in a split.
72-
;; TODO: setup the special mode for the buffer.
73-
;;
62+
(let ((buffer (get-buffer-create "*SEPL REPL*")))
7463
(with-current-buffer buffer
7564
(apply 'make-comint-in-buffer "SEPL" buffer '("localhost" . 42069) nil '())
7665
(sepl-repl-mode)
7766
(pop-to-buffer buffer))))
7867

68+
(defun sepl-repl-start ()
69+
"Starts a new SEPL instance and starts a REPL interface."
70+
(interactive)
71+
(let ((glsl-file (buffer-file-name (current-buffer))))
72+
(start-process "sepl" "*SEPL-STDOUT*" sepl-program-bin glsl-file)
73+
;; give process 2 seconds to start
74+
(sleep-for 2)
75+
(sepl-repl-connect)))
7976

80-
81-
;; TODO: some keywords we cna
77+
(provide 'sepl-mode)

0 commit comments

Comments
 (0)