clojure-austin 2023-06-13

Some things from yesterday: https://github.com/metabase/hawk test runner An emacs function to insert a comment block:

(defun personal/insert-comment ()
  (interactive)
  (end-of-defun)
  (insert "\n")
  (insert "(comment\n  )\n")
  (clojure-backward-logical-sexp)
  (forward-char 1)
  (clojure-forward-logical-sexp)
  (insert "\n")
  (indent-according-to-mode))

🎉 2

function to capture a deftest in a register:

(defun personal/set-test ()
  (interactive)
  (if (clojure-top-level-form-p "deftest")
      (save-excursion
        (beginning-of-defun)
        (forward-char 1)
        (clojure-forward-logical-sexp)
        (clojure-forward-logical-sexp)
        (clojure-backward-logical-sexp)
        (set-register ?i (s-concat "(clojure.test/run-test " (thing-at-point 'symbol) ")"))
        (message "set i register to: %s" (get-register ?i)))
    (message "not looking at test")))
if you point is inside of a deftest form, this will save the test name in the register i with the form (clojure.test/run-test <test-name>) Requires the ns to be the test namespace. You could adapt this to grab the ns of the test file and then it would be fully qualified and run it anywhere.