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
Allow better code sending to shell #1232
Allow better code sending to shell #1232
Conversation
From the discussion in #1100 it looks like @jorgenschaefer was prefering to one single shell that has project root loaded in. He also mentioned that As a user theres only two things I want. (This is just my opinion though :P)
I don't see the use cases for the other options (Also I think I agree with you that asking every time isn't ideal). I think less code is better code :P but eh, let jorgen decide \o/ |
Well, the project-shell option should do what you want (on shell per project with project root loaded). Personally, while doing data analysis, I often end up having repositories containing a bunch of scripts that I want to start independently, that's why I like the possibility to have dedicated shells. You are absolutely right about code simplicity, I guess I will wait for more feedback to see if this really benefit the community. |
I fear that we are adding too much unneeded complexity here. @gopar: do you use the send-to-shell-commmands to send statements from the Python buffers to the standalone shell? Or do you just use it to type stuff manually? |
@rgemulla I usually never select a region of code to send to a shell. Mostly because the snippets of code I want to check need to know about the project (where other modules are, etc). Maybe we can only have one or two python shell commands and the rest be custom functions that the user can setup via looking up in the |
Also, @galaunay if you need to run python scripts independently, then you could either use |
@gopar So the only functionality you need from Elpy are commands to start a shell for the current project (and afterwards you manage them yourself), right? Then this is the wrong PR ;) -- Anyway, I think we may add two commands, one that creates a shell for the current buffer and one that creates a new shell for the current project. @galaunay The key question is whether we really need to associate a shell buffer with each input file or not. If so, I suggest minor changes: one option |
Well, if I am the only one to use dedicated shells, we should definitely get rid of it. We can however add a note somewhere in the documentation to explain how to manage shells interaction:
as I misunderstood @gopar PR, I don't think the project shell (as implemented here, i.e. shells dedicated to each projects) will be necessary once #1100 will be merged. @rgemulla we can add I will give it a try in the next days, to see where it goes. |
I am not sure if you are the only one using dedicated shells ;). And since you are doing the work, your workflow counts! Anyway, the advantage of having these as commands is that one can bind them to keys / run them interactively and support auto completion. But I am additionally in favor of updating the docs, in particular, mentioning that one can also fix the shell using a buffer-local variable (so that one does not have to call elpy-shell-set-local-shell). @jorgenschaefer What's your opinion? Drop dedicated shells + commands to switch the shell manually, or have more sophisticated functionality for setting the default shell to use? |
9dd6707
to
7809117
Compare
So, after thinking about the previous discussions:
I am concerned about the fact that If it sounds good for everyone, I still need to update tests and documentation. |
3 similar comments
Just some thoughts. Wouldn't it be easier to create 2 functions? One for project shell and the other for stand-alone/dedicated shells? That way the user knows whats happening. For example, right now If you have a function named Also, for creating multiple dedicated shells, you might want to look into Not sure if these suggestion sound like a good idea. I just don't want to add unnecessary maintenance and potentially burn out any of us from contributing :P |
Also, please let me know if any of my comments sounds harsh. I would hate to sound mean in any way. Sorry if I did! |
@galaunay I like these changes (but haven't tested them yet). Instead of having toggle-dedicated-shell, why not have set-local-shell with auto completions that include (1) all running python shells, (2) a "global" option (which clears the buffer-local variable), and (3) the "Pyhton[%s]" option? Also, do the buffer names include the leading/trailing star ( @gopar Some people (including me) often send commands from Python buffers to the corresponding shell. For us, it's not about starting shells, it's about which of the shells the commands get sent to. That being said, I guess one could have two different "start a shell" functions (one for here, one for in project root) plus a default one which chooses which one to take based on "elpy-use-project-root". |
@gopar with this implementation, the project root will always be on sys.path (dedicated shell or not). @gopar at this state, dedicated shell names are created using the name of the associated buffer ( @rgemulla This will definitely allows more modularity, I will make some tries to see if it is easily doable. |
Okay, I implemented a version of We will have to choose between |
This looks quite useful to me. I will play around with it as soon as I find some time and provide more feedback. |
Any update on merging this branch? I'd love the functionality in this branch. 😃 |
@ganesh-krishnan It's on my todo list. Thanks for showing your interest :) |
6fa8cc4
to
df67ef4
Compare
`elpy-shell-toggle-dedicated-shell` attaches a dedicated shell to the current buffer. `elpy-shell-set-local-shell` attaches a specific shell to the current buffer.
df67ef4
to
a725f76
Compare
Ok, to summarise a bit this meandering PR:
@rgemulla @gopar @ganesh-krishnan any proposition or remarks on this are welcome ! nb: I will add the additional needed tests if we reach a final decision. |
Nice! I gave a quick glance and looks good. 👍 |
Not sure if my input is still needed here. I prefer simplicity and fewer options, so this looks great. :-) |
c0c590b
to
330dd14
Compare
Ok, Thanks for the feedbacks. |
thanks @galaunay. much appreciated! |
@galaunay thanks. this is very useful for data sciences workflow. |
Apparently Elpy users have a wide variety of workflows that necessitate different relations between python buffers and interactive shells (see PR #839 and issues #1100 and #1197).
This is an attempt to allow all those different workflows while keeping the code simple.
This PR defines a new option
elpy-shell-code-sending-strategy
which can be used to control to which python shell the code should be sent.Available options are:
elpy-dedicated-shells
was non-nil. Each buffer send its code to a dedicated python shell. Functionality introduced by PR Fix dedicated shells support #839.elpy-shell-switch-python-shell
. Functionality discussed in multiple python session #1197.elpy-project-root
). Functionality discussed in Add project shell with project root in sys.path #1100.After implementing and testing it, I am not sure the ask option is really useful...
One advantage of this implementation is that code modifications are restrained in
elpy-shell-get-or-create-process
.I am waiting for some feedback on this before finalizing (notably updating the tests and the documentation).