ambevar-dotfiles/.emacs.d/lisp/init-sly-selector.el

48 lines
1.8 KiB
EmacsLisp

(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
(helm-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))))
(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)