about summary refs log tree commit diff stats
path: root/.emacs.d
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2022-10-05 16:29:18 +0100
committerDavid Morgan <djm_uk@protonmail.com>2022-10-05 16:29:18 +0100
commit81475f44b8c3b85b54f194d063ba6bb2f56c5117 (patch)
treec98468ec31ccce502b11850c7c6d59eb027684cb /.emacs.d
parent3f0c36c91e09cf557391791a9b90f3da568ff021 (diff)
downloaddotfiles-81475f44b8c3b85b54f194d063ba6bb2f56c5117.tar.gz
Add cider-jack-in-and-run-main
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/init-clojure.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/.emacs.d/lisp/init-clojure.el b/.emacs.d/lisp/init-clojure.el
index b76a237..6b2cf4e 100644
--- a/.emacs.d/lisp/init-clojure.el
+++ b/.emacs.d/lisp/init-clojure.el
@@ -66,9 +66,23 @@
 (use-package cider
   :diminish
   :config
+  (defvar cider-main-function "-main")
   (defun cider-repl-mode-hook-fn ()
     (display-line-numbers-mode -1)
     (subword-mode +1))
+  (defun run-and-unhook ()
+    (remove-hook 'cider-connected-hook 'run-and-unhook)
+    (run-main))
+  (defun run-main ()
+    (interactive)
+    (cider-insert-in-repl (concat "(" cider-main-function ")") t))
+  (defun cider-jack-in-and-run-main (arg &rest params)
+    (interactive "P")
+    (if (equal current-prefix-arg '(4))
+        (progn
+          (add-hook 'cider-connected-hook 'run-and-unhook)
+          (cider-jack-in params))
+      (cider-jack-in params)))
   (define-abbrev-table 'cider-repl-mode-abbrev-table
     '(("scl" "(eval `(sc.api/defsc ~(sc.api/last-ep-id)))" cider-repl-return)
       ("scs" "(sc.api/defsc*)" cider-repl-return)