Skip to content

Instantly share code, notes, and snippets.

@jamii jamii/gist:4053713
Created Nov 11, 2012

What would you like to do?
(defvar concerto-default-username (format "%s@%s" (user-login-name) (system-name)))
(defvar concerto-username nil)
(defvar concerto-broadcast-buffer-name "*concerto*")
(defun concerto-init-broadcast-buffer (connection buffer)
(with-current-buffer buffer
(message "Joining concerto as %s" concerto-username)
(setq buffer-read-only t)
(pop-to-buffer (current-buffer))))
(defun concerto-broadcast-buffer (&optional noprompt)
"Return the broadcast buffer, create if necessary."
(let ((buffer (get-buffer concerto-broadcast-buffer-name)))
(or (if (buffer-live-p buffer) buffer)
(let ((connection (get-process nrepl-connection-buffer)))
(concerto-init-broadcast-buffer connection (get-buffer-create concerto-broadcast-buffer-name))))))
(defun concerto-broadcast-handler (buffer)
(lexical-let ((buffer buffer))
(lambda (response)
((nrepl-dbind-response response (username broadcast)
(message "%s: %s" username broadcast))))))
(defun concerto-join-handler (buffer)
(nrepl-make-response-handler buffer
(lambda (buffer err)
(message (format "%s" err)))
(lambda (buffer)
(message "Joined!"))))
(defun concerto-join ()
(nrepl-send-request (list "op" "join"
"username" concerto-username)
(concerto-init-broadcast-buffer-handler concerto-concerto-buffer)))
(defun concerto (username)
(interactive (list (read-string "Username: " concerto-default-username nil concerto-default-username)))
(setq concerto-username username)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.