From 81475f44b8c3b85b54f194d063ba6bb2f56c5117 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Wed, 5 Oct 2022 16:29:18 +0100 Subject: Add cider-jack-in-and-run-main --- .emacs.d/lisp/init-clojure.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to '.emacs.d') 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) -- cgit 1.4.1-2-gfad0