SLY: Initialize Helm selector for "sbcl-ambrevar".

master
Pierre Neidhardt 2021-01-13 11:52:16 +01:00
parent c2d320d4df
commit db009aec5b
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
(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 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-connection ()
"Return the connection matching `ambrevar/sly-connection-name'."
(helm-sly-buffer-connection
(cl-first (cl-remove-if-not
#'ambrevar/helm-sly-buffer-p
(buffer-list)))))
(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
(ambrevar/helm-sly-connection)))
helm-sly-new
(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)