Permalink
Browse files

Using Comint for Emacs integration.

  • Loading branch information...
xkapastel committed Jan 18, 2019
1 parent 89ca8a8 commit 233ca249494f1d516267d5a4c642a8fa2705f03c
Showing with 13 additions and 2 deletions.
  1. +10 −1 emacs/denshi.el
  2. +3 −1 src/server/index.js
@@ -15,9 +15,18 @@
;; License along with this program. If not, see
;; <https:;;www.gnu.org/licenses/.

(defvar denshi-server-host "127.0.0.1"
"The Denshi language server's host.")

(defvar denshi-server-port 4000
"The Denshi language server's port.")

(defun denshi-connect ()
"Connect to a Denshi language server."
(interactive)
(message "Not implemented."))
(let* ((program (cons denshi-server-host denshi-server-port))
(buffer (make-comint "denshi" program)))
(switch-to-buffer buffer)
(message "Connected.")))

(provide 'denshi)
@@ -40,6 +40,7 @@ let shell = new Shell();
shell.send(moduleBody);

const serve = (shell, socket) => {
const prompt = "user@denshi\n> ";
let buf = "";
socket.setEncoding("utf8");
socket.on("data", (data) => {
@@ -49,7 +50,7 @@ const serve = (shell, socket) => {
while (index !== -1) {
let input = buf.substring(offset, index - offset);
let output = shell.send(input);
socket.write(`${output}\n`);
socket.write(`${output}\n${prompt}`);
offset = index + 1;
index = buf.indexOf("\n", offset);
}
@@ -64,6 +65,7 @@ const serve = (shell, socket) => {
console.log(`ERROR: ${error}`);
process.exit(1);
});
socket.write(prompt);
}

let server = net.createServer((socket) => serve(shell, socket));

0 comments on commit 233ca24

Please sign in to comment.