Fork me on GitHub
#emacs
<
2020-10-14
>
ozzloy02:10:51

if i'm in a clojure buffer, is there a shortcut to tell the cider repl to switch to this files namespace?

jumar03:10:40

@ozzloy_clojurians_net cider-repl-set-ns (in my settings C-c M-n n)

ozzloy03:10:26

is there a way to get a running repl to grab new dependencies added to deps.edn?

jumar03:10:00

I think there's but I don't use deps that much (using leiningen). A long time before it used to work with clj-refactor but that has been broken afaik. Check https://insideclojure.org/2018/05/04/add-lib/

ozzloy03:10:05

@jumar that worked to switch the namespace for me!

ag18:10:00

What's the best way un-align forms that were previously aligned vertically with M-x clojure-align?

mpenet18:10:15

clj-fmt 0.7.0 has a new flag for that

mpenet18:10:45

With emacs alone I dont know if that's feasible

mpenet18:10:57

With clj-fmt its with :remove-multiple-non-indenting-spaces? true

ag18:10:04

clj-fmt is painfully slow to execute as an external tool. jet --pretty is much faster, but it does manipulate the order of keys (not ideal). I'd like to find emacs-lisp way.

mpenet18:10:23

Yes but you'd do it once and then keep the codebase "clean" since by default no alignment happens.

mpenet18:10:59

If you need to do it back/forth it's another story

ag18:10:08

> Yes but you'd do it once and then keep the codebase "clean" I need this not for the large codebase chunks. Mostly for selected regions or current clojure-form. Reasons: I like to vertically align things (forms read better that way), in some teams that is not an established convention, people sometimes don't like it. That is why I'm looking for the exact opposite of M-x clojure-align

ag19:10:15

(defun clojure-unalign (beg end)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 (save-excursion
                   (let ((end (progn (end-of-defun)
                                     (point))))
                     (clojure-backward-logical-sexp)
                     (list (point) end)))))

  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (while (re-search-forward "\\s-+" nil t)
        (replace-match " "))
      (indent-region beg end))))

👍 3
bozhidar05:10:50

You might also suggest something like this for inclusion in clojure-mode.

ag15:10:42

Alright, will make a PR

ag19:10:15

(defun clojure-unalign (beg end)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 (save-excursion
                   (let ((end (progn (end-of-defun)
                                     (point))))
                     (clojure-backward-logical-sexp)
                     (list (point) end)))))

  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (while (re-search-forward "\\s-+" nil t)
        (replace-match " "))
      (indent-region beg end))))

👍 3