Fork me on GitHub
#emacs
<
2016-11-10
>
josh.freckleton18:11:44

is there a way to configure emacs+cider so that if I open a project with, say, a project.clj, emacs will split into a few frames, automatically find, say, core.clj, and start cider, showing the repl buffer in a given frame? And could I configure this on a per-project basis?

norman19:11:05

I assume you probably don’t really want to start a REPL when you open a project.clj. But if you do start cider from the project, you can use :main to set your starting namespace.

norman19:11:10

That gets you 90% there

norman19:11:25

If you don’t own the project to update main, I suggest may trying projectile. C-c p f core would work pretty well.

josh.freckleton19:11:31

@norman what I'm looking for is a bit of automation; as it stands, it takes a lot of key strokes to get all the right files, buffers, repl, etc. open and split into convenient windows... so a command that could launch all of that would be awesome!

norman19:11:44

Honestly, I’d put all the repl stuff in dev/user.clj and have shell command that opened the correct namespace in emacs instead of the project.

norman19:11:55

cider-jack-in and then (init) in the repl

norman19:11:09

and you have everything opened exactly the way you described

josh.freckleton19:11:22

Launching from shell sounds great. By dev/user.clj do you mean a project-local one, or a computer-global one? I'm not sure I see either way though, how that could direct emacs in opening files / windows in a configuration.

norman19:11:04

project-local, assuming it’s your project

norman19:11:44

when you open core.clj and C-c M-j to start cider, you’ll get your core.clj at the top and the repl at the bottom. You’ll be in the user namespace

norman19:11:08

Since you’d never want a repl to start automatically without being asked, that’s about as optimized as I can see getting there. Then if your user.clj has some sort of initialization function you can have it require the desired namespace and switch you into if you want

norman19:11:28

and start up any services or any other initialization you want for that project

norman19:11:39

Everyone has their own workflow desires, so perhaps that just doesn’t work well for you. No idea. Personally, I open project.clj. Start cider. Projectile to the namespace I want to be in, load and go

norman19:11:07

And that namespace is almost never core.clj…. 🙂

josh.freckleton19:11:07

that makes sense, and is all good advice. I think maybe what I was looking for was M-x read-my-mind

norman19:11:26

In any case, you can certainly write an emacs function that will split up things, open files and send nrepl commands however you want. If you need some advice on how to write that, I’m sure there are plenty of people here can also help out there.

josh.freckleton19:11:37

(it is emacs after all)

norman19:11:48

But there’s nothing like that built in.

norman19:11:20

maybe we need a M-x cider-jack-in-right-here

norman19:11:39

that would load the namespance you are in and switch you to it in the repl

josh.freckleton19:11:57

that wouldn't be tough to automate with an in-ns-related command

josh.freckleton19:11:09

but, not quite what i was looking for

norman19:11:21

cider already has commands for those things - they are just separate things to type

norman19:11:48

Hmm - it sounds exactly like what you are looking for, except you’d need to have the desired namespace open instead of being in project.clj

mitchelkuijpers19:11:00

I think you could also write some elisp to do this

chadhs19:11:56

is there a way to customize the cider modeline?

chadhs19:11:06

didn’t see anything in the manual

chadhs19:11:11

cider[clj:[email protected]:port] to [clj:namespace]

bolivier20:11:01

@rui.yang There’s a binding that overrides C-M-d on the mac. I think it’s hiding the dock. You can turn it off via terminal and restarting, and maybe also in the keyboard settings.

bolivier20:11:14

(it’s actually a word definition keyboard shortcut)

bolivier20:11:36

type defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 '<dict><key>enabled</key><false/></dict>’ into your terminal

bolivier20:11:42

and then restart the computer and it should be fixed