Skip to content

Commit c590c65

Browse files
dpsuttonbbatsov
authored andcommitted
Remove projects from inf-clojure except to serve as project root
No inferring of build commands. Just a simple api: - `m-x inf-clojure` and select or type a clojure startup command - `m-x inf-clojure-connect` and enter host and port These days clojure commands are incredibly simple and tooling gets in the way. Inf clojure just interacts with a repl process so you can follow tutorials and just type what the tutorial types in. Seems just as simple to define your own project functions as to develop a good override api and defcustoms. Update todo with removing CIDER hooks
1 parent 2cfc38f commit c590c65

File tree

2 files changed

+51
-101
lines changed

2 files changed

+51
-101
lines changed

inf-clojure.el

Lines changed: 41 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -408,45 +408,6 @@ If this is `nil`, the project will be automatically detected."
408408
:safe #'stringp
409409
:package-version '(inf-clojure . "2.1.0"))
410410

411-
(defcustom inf-clojure-lein-cmd "lein repl"
412-
"The command used to start a Clojure REPL for Leiningen projects.
413-
414-
Alternatively you can specify a TCP connection cons pair, instead
415-
of command, consisting of a host and port
416-
number (e.g. (\"localhost\" . 5555)). That's useful if you're
417-
often connecting to a remote REPL process."
418-
:type '(choice (string)
419-
(cons string integer))
420-
:risky #'stringp
421-
:safe #'inf-clojure--endpoint-p
422-
:package-version '(inf-clojure . "2.0.0"))
423-
424-
(defcustom inf-clojure-boot-cmd "boot repl -C"
425-
"The command used to start a Clojure REPL for Boot projects.
426-
427-
Alternatively you can specify a TCP connection cons pair, instead
428-
of command, consisting of a host and port
429-
number (e.g. (\"localhost\" . 5555)). That's useful if you're
430-
often connecting to a remote REPL process."
431-
:type '(choice (string)
432-
(cons string integer))
433-
:risky #'stringp
434-
:safe #'inf-clojure--endpoint-p
435-
:package-version '(inf-clojure . "2.0.0"))
436-
437-
(defcustom inf-clojure-tools-deps-cmd "clojure"
438-
"The command used to start a Clojure REPL for tools.deps projects.
439-
440-
Alternatively you can specify a TCP connection cons pair, instead
441-
of command, consisting of a host and port
442-
number (e.g. (\"localhost\" . 5555)). That's useful if you're
443-
often connecting to a remote REPL process."
444-
:type '(choice (string)
445-
(cons string integer))
446-
:risky #'stringp
447-
:safe #'inf-clojure--endpoint-p
448-
:package-version '(inf-clojure . "2.1.0"))
449-
450411
(defcustom inf-clojure-generic-cmd "lein repl"
451412
"The command used to start a Clojure REPL outside Lein/Boot projects.
452413
@@ -688,7 +649,7 @@ to continue it."
688649
(t str)))
689650

690651
(defvar inf-clojure-project-root-files
691-
'("project.clj" "build.boot" "deps.edn")
652+
'("project.clj" "build.boot" "deps.edn" "shadow-cljs.edn")
692653
"A list of files that can be considered project markers.")
693654

694655
(defun inf-clojure-project-root ()
@@ -702,29 +663,52 @@ Fallback to `default-directory.' if not within a project."
702663
inf-clojure-project-root-files)))
703664
default-directory))
704665

705-
(defun inf-clojure-project-type ()
706-
"Determine the type, either leiningen or boot of the current project."
707-
(or inf-clojure-project-type
708-
(let ((default-directory (inf-clojure-project-root)))
709-
(cond ((file-exists-p "project.clj") "lein")
710-
((file-exists-p "build.boot") "boot")
711-
((file-exists-p "deps.edn") "tools.deps")
712-
(t "generic")))))
713-
714-
(defun inf-clojure-cmd (project-type)
715-
"Determine the command `inf-clojure' needs to invoke for the PROJECT-TYPE."
716-
(pcase project-type
717-
("lein" inf-clojure-lein-cmd)
718-
("boot" inf-clojure-boot-cmd)
719-
("tools.deps" inf-clojure-tools-deps-cmd)
720-
(_ inf-clojure-generic-cmd)))
721-
722666
(defun inf-clojure-clear-repl-buffer ()
723667
"Clear the REPL buffer."
724668
(interactive)
725669
(let ((comint-buffer-maximum-size 0))
726670
(comint-truncate-buffer)))
727671

672+
(defun inf-clojure-switch-to-repl (eob-p)
673+
"Switch to the inferior Clojure process buffer.
674+
With prefix argument EOB-P, positions cursor at end of buffer."
675+
(interactive "P")
676+
(if (get-buffer-process inf-clojure-buffer)
677+
(let ((pop-up-frames
678+
;; Be willing to use another frame
679+
;; that already has the window in it.
680+
(or pop-up-frames
681+
(get-buffer-window inf-clojure-buffer t))))
682+
(pop-to-buffer inf-clojure-buffer))
683+
(call-interactively #'inf-clojure))
684+
(when eob-p
685+
(push-mark)
686+
(goto-char (point-max))))
687+
688+
(defun inf-clojure-quit (&optional buffer)
689+
"Kill the REPL buffer and its underlying process.
690+
691+
You can pass the target BUFFER as an optional parameter
692+
to suppress the usage of the target buffer discovery logic."
693+
(interactive)
694+
(let ((target-buffer (or buffer (inf-clojure-select-target-repl))))
695+
(when (get-buffer-process target-buffer)
696+
(delete-process target-buffer))
697+
(kill-buffer target-buffer)))
698+
699+
(defun inf-clojure-restart (&optional buffer)
700+
"Restart the REPL buffer and its underlying process.
701+
702+
You can pass the target BUFFER as an optional parameter
703+
to suppress the usage of the target buffer discovery logic."
704+
(interactive)
705+
(let* ((target-buffer (or buffer (inf-clojure-select-target-repl)))
706+
(target-buffer-name (buffer-name target-buffer)))
707+
;; TODO: Try to recycle the old buffer instead of killing and recreating it
708+
(inf-clojure-quit target-buffer)
709+
(call-interactively #'inf-clojure)
710+
(rename-buffer target-buffer-name)))
711+
728712
;;;###autoload
729713
(defun inf-clojure (cmd)
730714
"Run an inferior Clojure process, input and output via buffer `*inf-clojure*'.
@@ -821,22 +805,6 @@ Prefix argument AND-GO means switch to the Clojure buffer afterwards."
821805
(inf-clojure-eval-last-sexp)
822806
(forward-sexp))
823807

824-
(defun inf-clojure-switch-to-repl (eob-p)
825-
"Switch to the inferior Clojure process buffer.
826-
With prefix argument EOB-P, positions cursor at end of buffer."
827-
(interactive "P")
828-
(if (get-buffer-process inf-clojure-buffer)
829-
(let ((pop-up-frames
830-
;; Be willing to use another frame
831-
;; that already has the window in it.
832-
(or pop-up-frames
833-
(get-buffer-window inf-clojure-buffer t))))
834-
(pop-to-buffer inf-clojure-buffer))
835-
(inf-clojure (inf-clojure-cmd (inf-clojure-project-type))))
836-
(when eob-p
837-
(push-mark)
838-
(goto-char (point-max))))
839-
840808
(defun inf-clojure-insert-and-eval (form)
841809
"Insert FORM into process and evaluate.
842810
Indent FORM. FORM is expected to have been trimmed."
@@ -1411,30 +1379,6 @@ Useful for commands that can invoked outside of an ‘inf-clojure’ buffer
14111379
(t (get-buffer (completing-read "Select target inf-clojure buffer: "
14121380
(mapcar #'buffer-name repl-buffers))))))))
14131381

1414-
(defun inf-clojure-quit (&optional buffer)
1415-
"Kill the REPL buffer and its underlying process.
1416-
1417-
You can pass the target BUFFER as an optional parameter
1418-
to suppress the usage of the target buffer discovery logic."
1419-
(interactive)
1420-
(let ((target-buffer (or buffer (inf-clojure-select-target-repl))))
1421-
(when (get-buffer-process target-buffer)
1422-
(delete-process target-buffer))
1423-
(kill-buffer target-buffer)))
1424-
1425-
(defun inf-clojure-restart (&optional buffer)
1426-
"Restart the REPL buffer and its underlying process.
1427-
1428-
You can pass the target BUFFER as an optional parameter
1429-
to suppress the usage of the target buffer discovery logic."
1430-
(interactive)
1431-
(let* ((target-buffer (or buffer (inf-clojure-select-target-repl)))
1432-
(target-buffer-name (buffer-name target-buffer)))
1433-
;; TODO: Try to recycle the old buffer instead of killing and recreating it
1434-
(inf-clojure-quit target-buffer)
1435-
(inf-clojure (inf-clojure-cmd (inf-clojure-project-type)))
1436-
(rename-buffer target-buffer-name)))
1437-
14381382
(defun inf-clojure--response-match-p (form match-p proc)
14391383
"Send FORM and apply MATCH-P on the result of sending it to PROC.
14401384
Note that this function will add a \n to the end of the string

todo.org

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ The source primitive is quite nice but we most likely need a way to navigate to
5050
** TODO PREPL
5151
Be nice to implement this now that we have parseedn in elisp to understand edn.
5252
* Nice-to-haves
53-
54-
** TODO Better handling of cyclic dependencies
55-
In inf-clojure.el I load the implementation specific files for lumo, planck, etc _after_ defining the register function. I would much prefer a way to do this without being so fragile.
56-
5753
** TODO Put repl type in modeline
5854
Rather than just ~*inf-clojure*~ we could put the repl type. Make it easy to follow and makes it easy to see when it gets it wrong.
55+
56+
** TODO How do CIDER and inf-clojure play nice on the same emacs?
57+
inf-clojure and CIDER are fighting over the keymappings. I've been doing a bit of a kludge to remove CIDER's tentacles from my clojure files for developing:
58+
#+BEGIN_SRC emacs-lisp
59+
(seq-doseq (buffer (buffer-list))
60+
(with-current-buffer buffer
61+
(cider-mode -1))
62+
(remove-hook 'clojure-mode-hook #'cider-mode))
63+
#+END_SRC
64+
Seems a bit heavy handed but its working for me so far.

0 commit comments

Comments
 (0)