Fork me on GitHub
#emacs
<
2019-08-25
>
st3fan15:08:50

what is the proper way in clojure-mode to change a [1 2 3] to a #{1 2 3}? I’ve been switvhing to text-mode to be able to actually change the brackets, which is … not ideal 🙂

bhagany15:08:56

I think this is probably due to paredit or smartparens depending on which you have installed, rather than clojure-mode itself

bhagany15:08:17

if paredit, I can give you the steps I take, and I'd be happy if anyone had something better --

st3fan15:08:23

oh it seems clojure-mode uses smartparens - i should google that first before asking

bhagany15:08:21

it's not quite like that -- there's probably a hook in your configuration somewhere that turns on smartparens when clojure-mode is enabled

bhagany15:08:50

anyway, here are my steps for paredit. smartparens is probably similar:

bhagany15:08:23

starting with

[1 2 3]
I put my cursor on the opening bracket and type #, leaving
#[1 2 3]

bhagany15:08:10

then, I use paredit-wrap-curly, which I bound to M-{, which leaves me with

#{[1 2 3]}

bhagany15:08:37

from there, I put my cursor on the 1, and use paredit-splice-sexp-killing-backward, bound to M-up, which leaves me at the desired result

#{1 2 3}

bhagany15:08:08

(sorry, edited that last one, I always get confused between M-up and M-r)

st3fan15:08:40

this is great - i think i need to spend a bit of time mapping some of these to keys

👍 4
st3fan15:08:46

Ok now I also see how i can much easier change a string to a keyword with M-r

bhagany15:08:55

ah, that's excellent, I don't think I've done it that way

dpsutton15:08:26

Clojure mode has a cycle collection type. I’m not at a computer but it’s in there

dpsutton16:08:06

C-c C-r # for a set, { for a map, [ for a vector and ( for a list

👍 4
bhagany16:08:43

oooooooooooooo

bhagany16:08:17

well that's much better

David Pham16:08:34

I learn every day :)

💯 4
☝️ 4
dpsutton17:08:10

I always forget how much nice stuff is in there

Lone Ranger17:08:33

typically what I'll do to solve @st3fan’s issue is ... oh, exactly what @bhagany said

bhagany17:08:09

I've tried @dpsutton’s suggestion, and it's far superior

dpsutton17:08:45

i didn't know about M-up so i'm stoked about that one. but in this instance it looks like the clojure-mode refactorings are built to do exactly what is desired here

parrot 4
st3fan18:08:37

I’m still a noob after 20 years of Emacs. Always something new to learn :-)

Lone Ranger18:08:37

okay this is driving me bananas

(s/def ::platform 
  (s/keys 
   :req [:platform/description
         :platform/codeShortName
         :platform/searchTab
         :platform/vendorShortName
         :platform/vendor
         :platform/id]   ))
see that little whitespace at the end? I've tried TAB, clojure-align, C-M-\ ... that whitespace is very persistent

Lone Ranger18:08:31

I've also done (setq clojure-align-forms-automatically t) in init.el.

Lone Ranger18:08:45

anyone have any suggestions for auto-killing the whitespace?