-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cider-jack-in-with-profile #544
Conversation
It's definitely a good idea, however, I can certainly imagine someone wanting to specify both a project dir and a profile together, so I think it might be much simpler to just keep a single prefix arg and ask the users to input both params (with some reasonable pre-filled defaults). |
That's true, with the current project was filled out as the default, hitting enter is no great inconvenience, likewise if the default profile was selected. I've never really used prefix arguments before so didn't really think of it. Would you like me to make the changes and re-submit a pull request with a single commit? Or should I just alter this one? |
Add commits to your current branch, squash them together into one and force push. Best way to update a PR IMO. :-) |
P.S. You should also mention the updated functionality in the changelog. |
This should close #327 too. |
I've made the changes as suggested, and the resulting commit is a lot smaller and neater. I've tested it with all my projects (both with profiles and simpler ones without) and all seems well here. |
Chatting to gtrak and technomancy in IRC, they have raised the possibility of leaving the cider-server-command string where it was (which means that it's amenable to local-dir-vars if you want to set the command for a specific project) and that instead of prompting for a profile and then munging it into the lein repl command, we actually display the whole command string, pre populated with the default, and allow the user to make arbitrary changes, for example 'lein with-profile blah do clean, compile, repl' |
:-D +1 On Wed, Apr 30, 2014 at 12:42 PM, AdamClements [email protected]:
|
I guess this makes some sense. I'm not opposed to their idea. P.S. Why are there no cider discussions every time I'm on #clojure? :-) |
@bbatsov*, *your time zone must be set incorrectly. Don't worry, I am double agent, born in Moldova :-). (Hi NSA!) On Wed, Apr 30, 2014 at 12:47 PM, Bozhidar Batsov
|
@AdamClements Let me know when you've updated the PR (again). :-) @gtrak Not a lot of Clojure hackers in (Eastern) Europe unfortunately. Seems that the party is mostly state-side at this point. :-) |
@bbatsov is that the route you'd prefer then? I was checking for more opinions before I did any work on it. I'm not too bothered either way myself, the existing pull request scratches my own itch and solves #327, and has the advantage of not requiring any more work ;-). If you think the added flexibility of editing the whole leiningen command is important though, then I'm happy to make the changes |
I also think there's a slight usability benefit to know that cider is Showing the command will lead one to know the specific dependency on what On Wed, Apr 30, 2014 at 1:13 PM, AdamClements [email protected]:
|
@AdamClements I think it'd be nice to keep the command as a defcustom, so people could override it on a per-project basis. Let's go with @gtrak's idea and give users the ability to edit the entire lein command. |
Or we can go the extra fancy way and introduce a second prefix argument |
I think that would be a bit confusing and undiscoverable. I didn't actually know how prefix arguments worked before writing this feature. Why not have a few extra jack-in commands called something like cider-jack-in-with-profile and cider-jack-in-custom. I don't know about anyone else, but when I want to do something, I hit m-x, enter an appropriate prefix and then tab through the available options to discover new features. |
I was actually planning the retire the |
Oh, really? I like cider-jack-in. What would happen to the current functionality of just cider? Anyway, I think the simpler thing to do is just have the one version which allows you to edit the whole command, it's not like the profiles prompt is going to save an awful lot of keystrokes and if it gets very tiresome, you can just set the default for a project. |
It was recently renamed to cider-connect. Let's go with editing the whole command. |
When editing the whole cider-server-command, on some platforms the whole command includes 'echo "lein repl :headless" | eval $SHELL -l'. Is that a detail we don't mind exposing in the prompt for cider-jack-in? It's quite hard to hide it without then taking away the ability to customise it, and I don't know who might be customising that. I think it's a detail we could reasonably hide, but then the decision about whether to use that or not is based on whether cider-lein-command is visible on the path, so we couldn't offer the string for arbitrary editing and then make that check because the user might change which executable we're looking for! Do we know what the ramifications would be of changing this to always eval $SHELL -l in which case we could change this to simply lein repl :headless and allow editing, forget all this complication. |
@AdamClements I don't even know why the |
One of my computers actually uses that variant - when I run emacs from my interactive shell, it hasn't run my .bashrc and so my bin folder containing leiningen isn't on the classpath. I think that's why it pipes it through $SHELL so it runs the appropriate rc file. I might be wrong though... |
Interactive shells would source both |
One more thing - the |
So my fairly stock ubuntu, emacs 24 + prelude setup doesn't work without the eval $SHELL -l option. I think it must be whether you have it on your system PATH or your user PATH... not sure. Either way I think perhaps it would be safer to do the eval all the time instead, which simplifies just as much. Can you think of any down sides to that? The only problem I have now is getting the output of the nrepl to say if the command has failed completely, as it stands it just fails silently and connects to any available repl... not ideal. Any ideas? |
How did you install leiningen? What does your |
As per the readme, I installed it in ~/bin/lein, ~/bin is in my $PATH and my exec-path is only ("/usr/local/sbin" "/usr/local/bin" "/usr/sbin" "/usr/bin" "/sbin" "/bin" "/usr/games" "/usr/local/games" "/usr/lib/emacs/24.3/x86_64-linux-gnu") |
This seems related to your problem - http://stackoverflow.com/questions/6411121/how-to-make-emacs-to-use-my-bashrc-file Btw, Prelude, actually uses the package mentioned in the accepted answer, but enables it only for OS X. I guess it might be useful on Ubuntu as well. In the end the |
I agree we should drop this hack, but we should also make it obvious what On Tue, May 6, 2014 at 2:28 PM, Bozhidar Batsov [email protected]:
|
Come to think of it, I think I'd rather prefer always running through On Tue, May 6, 2014 at 2:32 PM, Gary Trakhman [email protected]:
|
I've been frustrated at other editors for doing the same thing and making On Tue, May 6, 2014 at 2:35 PM, Gary Trakhman [email protected]:
|
@gtrak That's a terrible idea as you'd get a different environment for the process, compared to the one for Emacs. I've been hacking on Emacs extensions for years and (almost) nobody does it this way; we shouldn't either. |
Emacs's getenv shows the needed PATH pointing to ~/bin, which occurs Meanwhile, I'm manually running setenv in my init.el. I had to do this to enable the G1 garbage collector in leiningen's JVM, not just the project JVM, which has real memory space benefits. On Tue, May 6, 2014 at 2:39 PM, Bozhidar Batsov [email protected]:
|
Pretty sure this is an OS X/Ubuntu/Debian fault, not Emacs's. Anyways, installing exec-path-from-shell solves this. |
@bbatsov, you're right. I verified that emacs has the right environment If emacs passes along its environment to its child processes, lein in this On Tue, May 6, 2014 at 2:49 PM, Bozhidar Batsov [email protected]:
|
@AdamClements Ping :-) |
Okay then, I'll remove the hack. If we do that then we could also support Lein command separately to the parameters which would be a bit nicer. I'm a little worried how many people this will break things for, how will we go about informing them? Would it make sense to depend on the package you mentioned to fix the path? Hope to get a bit of time to do this over the weekend. |
They don't really need this package, they just need a properly configured |
I made the changes, and all the config looks right, it can find lein in the path, but it seems to hang at "Connecting to nREPL" for me now. I know it's running the process, because it shows any errors that come up when starting lein, but the nrepl never seems to show up... |
@AdamClements See this issue #561 for tips on debugging the startup sequence. |
…es a working exec-path by default
Fixed. There was a typo in one of the var names. Now works for me, but please test. So, in this latest iteration, cider-lein-command does an executable-find of either lein or lein.bat, and sets itself appropriately, but you can of course override it. Separately to this, I have replaced cider-server-command with cider-lein-parameters which is a simple string, defaulting to "repl :headless". Now all it does is cd to the project directory and run the cider-lein-command with the cider-lein-parameters. If you do a prefix argument, you get the option to set the parameters for a given cider-jack-in as well as the project path. |
Add cider-jack-in-with-profile
To summarize for other noobs like me, who might read this PR and erroneously conclude that cider-jack-in-with-profile is a function available in emacs…if you want to
or to set it interactively (so you can see it's current value before changing it):
That'll cause your next |
@Bill You can also invoke |
I have a cross platform leiningen project with multiple profiles, for which I need to have repls which start with different profiles. At the moment I have to do
lein with-profile :local-test repl :headless
manually which leaves a terminal floating around separate to my emacs window, and also leaves me not knowing which terminals are linked to which emacs windows.I've proposed a cider-jack-in-with-profile interactive function, as cider-jack-in already had an optional parameter and so couldn't be overridden. This duplicated most of cider-jack-in and so I have split out the common functionality, cider-jack-in should be functionally unaffected.
Please feel free to advise on style and appropriate locations for functions. I needed to make cider-server-command more flexible and so moved it into a function, which means that the locate-file might need to happen more than once, but a jack-in is a relatively infrequent action anyway, so I don't know how much this matters.