lang/clojure: fix repl handler #1714
This commit is contained in:
parent
bb71f591f8
commit
9857b3d481
2 changed files with 21 additions and 4 deletions
|
@ -13,10 +13,26 @@ at point."
|
||||||
;;; Commands
|
;;; Commands
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +clojure/open-repl (&optional arg)
|
(defun +clojure/open-repl (&optional arg type)
|
||||||
"Open a Cider REPL and return the buffer."
|
"Open a Cider REPL for clojure and return the buffer."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(process-buffer (cider-jack-in arg)))
|
;; TODO Better error handling
|
||||||
|
(let ((type (or type 'clj)))
|
||||||
|
(if-let (buffer (cider-current-repl type))
|
||||||
|
(pop-to-buffer buffer)
|
||||||
|
(let ((process (cider-jack-in-clj arg)))
|
||||||
|
(message "Starting CIDER server for the first time...")
|
||||||
|
(while (and (process-live-p process)
|
||||||
|
(not (cider-current-repl type)))
|
||||||
|
(sit-for 1))
|
||||||
|
(message "Starting CIDER server for the first time...done")
|
||||||
|
(pop-to-buffer (cider-current-repl type))))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +clojure/open-cljs-repl (&optional arg)
|
||||||
|
"Open a Cider REPL for clojurescript and return the buffer."
|
||||||
|
(interactive "P")
|
||||||
|
(+clojure/open-repl arg 'cljs))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +clojure/cider-switch-to-repl-buffer-and-switch-ns ()
|
(defun +clojure/cider-switch-to-repl-buffer-and-switch-ns ()
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
:init
|
:init
|
||||||
(after! clojure-mode
|
(after! clojure-mode
|
||||||
(set-repl-handler! 'clojure-mode #'+clojure/open-repl)
|
(set-repl-handler! 'clojure-mode #'+clojure/open-repl)
|
||||||
(set-eval-handler! 'clojure-mode #'cider-eval-region))
|
(set-repl-handler! 'clojurescript-mode #'+clojure/open-cljs-repl)
|
||||||
|
(set-eval-handler! '(clojure-mode clojurescript-mode) #'cider-eval-region))
|
||||||
:config
|
:config
|
||||||
(add-hook 'cider-mode-hook #'eldoc-mode)
|
(add-hook 'cider-mode-hook #'eldoc-mode)
|
||||||
(set-lookup-handlers! 'cider-mode
|
(set-lookup-handlers! 'cider-mode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue