This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (1)
- # autochrome-github (1)
- # babashka (9)
- # beginners (112)
- # bristol-clojurians (2)
- # calva (26)
- # cider (10)
- # clj-kondo (31)
- # cljs-dev (40)
- # clojure (114)
- # clojure-austin (1)
- # clojure-dev (112)
- # clojure-europe (22)
- # clojure-germany (5)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-spec (10)
- # clojure-uk (96)
- # clojurescript (39)
- # core-logic (5)
- # crux (15)
- # datomic (40)
- # fulcro (34)
- # graphql (17)
- # jobs (3)
- # kaocha (4)
- # leiningen (10)
- # luminus (1)
- # malli (3)
- # meander (44)
- # midje (2)
- # off-topic (40)
- # pathom (5)
- # re-frame (8)
- # reitit (8)
- # ring (3)
- # ring-swagger (4)
- # shadow-cljs (83)
- # spacemacs (96)
- # tools-deps (16)
- # vim (4)
- # yada (20)
, e p will pretty print into a new buffer, The contents could then be copied into your source code buffer and put in as a comment. Select the expression and press
g c to comment it.
You can also do
SPC SPC cider-pprint-eval-defn-to-comment and same for last-sexp. If I can think of good keybindings, I can add them...
OK, that last function was what I was asking for. I can just assign that to some keybinding.
What keybinding in the Clojure major mode menu would make sense in your opinion? I would like to add it to Spacemacs.
, e p ;. I'm not super experienced with Spacemacs, but that seems natural.
I don't understand the difference between the
eval-defn family of commands and the
defn evaluates the top level expression (the parent form), last-sexp evaluates the expression/form before the cursor (or on the previous line).
I find last-sexp most useful for evaluating expressions nested inside other expressions
The cider docs don't seem to be very informative on the different functions, do you have any suggestions on where I can go to find information on the different cider functions in emacs?
Well you could read my book 🙂 One day it will be finished, but hopefully has enough to help you https://practicalli.github.io/spacemacs/
I've also been having trouble with CIDER putting the result-comments on the same line as the expression sometimes, do you know how to fix that?
It seems to do that when no new line is below the code you are evaluating, i.e. at the end of the file.
Either create a new line or use
C-j as the start of the comment to move it to the next line
Hello everyone, I am considering a pull request to add some more pprint keybindings. Feedback is appreciated
"e;" 'cider-eval-defun-to-comment "ep;" 'cider-pprint-eval-defun-to-comment "epf" 'cider-pprint-eval-defun-at-point "epe" 'cider-pprint-eval-last-sexp "epE" 'cider-pprint-eval-last-sexp-to-comment
The PR is https://github.com/syl20bnr/spacemacs/pull/13421 (I had to push an amended commit, so it may take a few days to be cherry picked into Spacemacs)
, e ; currently runs
cider-eval-defun-to-comment. It looks like he's proposing moving that to
e; and replacing it with
cider-pprint-eval-defun-to-comment. Emphasis on the
This function is pretty useful to me, might be worth adding:
(defun cider-eval-parent-sexp () "Evaluate the immediate parent sexp" (interactive) (save-excursion (sp-end-of-sexp) (evil-jump-item) (cider-eval-sexp-at-point))) (spacemacs|forall-clojure-modes m (spacemacs/set-leader-keys-for-major-mode m "e." 'cider-eval-parent-sexp))
essentially, you can evaluate the surrounding sexp, without having to navigate to the end/beginning
C-c C-c to evaluate toplevel expressions inside comments.
Thoughts on what would be most sane to use?
(setq clojure-toplevel-inside-comment-form 't)
Anyone else have an issue where
, t t doesn't always show the results in the minibuffer?
I'm finding that sometimes the test result gets hidden by what looks like an evaluation result.
Any idea why Spacemacs becomes awfully slow when setting
(set! *warn-on-reflection* true) ?
Is it Emacs or is it adding more overhead for Clojure? Are you actually getting reflection warnings?
I am getting reflection warnings but I think this has more to do with CIDER than anything. Once I close the repl everything is fast again.
are you using master or development branch? o the dev branch it comes with the clojure layer already (if Im not mistaken)
dotspacemacs-configuration-layers change the clojure layer to this config and the bindings should show up
(clojure :variables clojure-enable-linters '(clj-kondo) clojure-enable-clj-refactor t)
if you are not using
clj-kondo (its a linter, no related to your question but any way..) I strongly advise you to do so, once again, its very easy to setup, just install it on your machine , add that line to
.spacemacs and should be working
clj-refactor was causing issues so I had uninstalled it. But let me give it a go and see if its still wonky
@mario.cordova.862 or you could use the Emacs tools, eg.
SPC s p followed by
C-c C-e to put all the results in a buffer
I use this approach to refactor names across a project, eg. https://practicalli.github.io/spacemacs/refactor/within-a-project.html
Would this catch instances of calling a function with a namespace prefix such
(my-ns/function-name args) ?
Yes, its a text search, so it will match what ever you search for. It doesn't rely on the REPL or static analysis.
Ah, well I could just use
SPC / this works relatively well. Although for some odd reason its returning results for files that should be ignored
With either keybinding you can pass arguments to the search. If you have ripgrep binary installed, they you can pass search arguments `-g*.clj` to just search *.clj files, or `-g!*.md` to exclude searching *.md files
I was under the assumption that
SPC / will search all files in project but will ignore files that are set in the
Yes, it should do, although I stopped using that keybinding as it has a few annoyances (weird vim things if you forget to press RTN, have to clear the search highlighting by deleting it).
Here are some examples of using the option with a search https://practicalli.github.io/spacemacs/working-with-projects/searching-projects.html
I recommend installing ripgrep or at least silver-searcher (ag) if you havent already, they are much faster and more reliable than grep.
I think clj-refactor is a bit more reliable than it used to be, however, I found I haven't missed it over the last year. It's good to have options 😁
Threading refactoring is already part of clojure-mode, so clj-refactor is not needed for that. In fact I just used thread-last refactor yesterday thanks to your reminder about it.
@plins could you clarify what clear the namespace does? I assume you mean remove (undefine) the definitions in the current namespace. I thought that was part of CIDER itself (I could be wrong).
I think its part of CLJR, also besides removing the unused requires/definitions I think it also sort the requires in alphabetical order
Oh yes, I looked at the link. That refactor command does more than I would want it too personally. I prefer to group dependencies and requires by their purpose rather than how they are spelt. For unused requirements, then clj-kondo has that covered and is my preferred approach, as I prefer to learn by making those changes myself. However, thats just my approach and its interesting to know how others work.
I never really used it. I need to discipline myself to use more of the structural editing. starting getting into the habit of using
spc k r, spc k t, spc k c . These keybindings are powerful
does ag have the same
-g options for specifying patters? I know it can do the same, just cant remember if the option names are the same.