55 lines
2.3 KiB
EmacsLisp
55 lines
2.3 KiB
EmacsLisp
(require 'sly-mrepl) ; For `sly-mrepl--find-buffer'.
|
|
|
|
(defvar ambrevar/sly-connection-name "sbcl-ambrevar")
|
|
(defun ambrevar/helm-sly-buffer-p (buffer)
|
|
"Return non-nil if BUFFER has a SLY connection matching
|
|
`ambrevar/sly-connection-name'."
|
|
(with-current-buffer buffer
|
|
(and (derived-mode-p 'sly-mrepl-mode)
|
|
sly-buffer-connection
|
|
(sly-process sly-buffer-connection)
|
|
(string-prefix-p ambrevar/sly-connection-name
|
|
(sly-connection-name sly-buffer-connection)))))
|
|
|
|
(defun ambrevar/helm-sly-mini ()
|
|
"Helm for Lisp connections and buffers using the
|
|
`ambrevar/sly-connection-name' connection."
|
|
(interactive)
|
|
(helm :sources (list (helm-sly--c-source-connection
|
|
(helm-sly--repl-buffer-candidates
|
|
nil #'ambrevar/helm-sly-buffer-p)
|
|
"Ambrevar's Lisp connections")
|
|
helm-sly-new
|
|
(helm-sly-lisp-buffer-source)
|
|
(helm-sly-build-buffers-source))
|
|
:buffer "*ambrevar/helm-sly-mini*"))
|
|
|
|
(defun ambrevar/helm-selector-sly ()
|
|
"Helm for `sly' buffers using the `ambrevar/sly-connection-name' connection."
|
|
(interactive)
|
|
(helm-selector
|
|
"Ambrevar SLY-REPL"
|
|
:predicate #'ambrevar/helm-sly-buffer-p
|
|
:make-buffer-fn (lambda ()
|
|
(interactive)
|
|
(let ((sly-lisp-implementations
|
|
(list
|
|
(assoc (intern ambrevar/sly-connection-name)
|
|
sly-lisp-implementations)))
|
|
(current-connection (car (sly--purge-connections))))
|
|
(if (and current-connection
|
|
(sly-mrepl--find-buffer current-connection)
|
|
(ambrevar/helm-sly-buffer-p
|
|
(sly-mrepl--find-buffer current-connection)))
|
|
(call-interactively #'sly)
|
|
(sly))))
|
|
:helm-sources #'ambrevar/helm-sly-mini))
|
|
|
|
(defun ambrevar/helm-selector-sly-other-window ()
|
|
"Like `ambrevar/helm-selector-sly' but raise buffer in other window."
|
|
(interactive)
|
|
(let ((current-prefix-arg t))
|
|
(call-interactively #'helm-selector-sly)))
|
|
|
|
(provide 'init-sly-selector)
|