elpy icon indicating copy to clipboard operation
elpy copied to clipboard

ESS-style send current "chunk" feature implementation

Open dwcoates opened this issue 8 years ago • 10 comments

ESS, emacs' R mode (an excellent package, btw), has as default behavior its C-c C-c send all code between the two nearest blank lines before and after point. It has also the nifty feature of flashing a highlight of this code chunk as you press C-c C-c. I can't find an equivalent for elpy. Am I missing something, and if not, is this an interesting feature for the elpy package?

dwcoates avatar Mar 08 '17 04:03 dwcoates

Hello, and thanks for the suggestion! This is one of these things that is useful for Numpy/Scipy users, who use Python interactively a lot, but much less useful for people who use Python more for software development than statistics and interactive work. I'm always torn as to how much to support the former workflow. I can see adding such a command to elpy, but I would not bind it to a key by default, especially not C-c C-c

jorgenschaefer avatar Mar 10 '17 14:03 jorgenschaefer

Maybe with a prefix arg? C-u C-c C-c. Seems a bit long-winded, though. C-c RET is an option.

dwcoates avatar Mar 10 '17 15:03 dwcoates

I'm happy to implement this and file a pull request, btw. Just let me know your thoughts on bindings and behavior. I like the flashing effect, for example, as well as the automatically navigating to the next code chunk after evaluation.

dwcoates avatar Mar 10 '17 17:03 dwcoates

For normal Python development, I have never really had the need to send individual lines in a file. That's why Elpy's C-c C-c sends the full file if there is no active region.

I can totally see providing a command that users then can bind themselves for this kind of work. I can also see adjusting the C-RET behavior, maybe. Not sure. I do not have the ipython/scipy/numpy interactive use case myself, at all, so I have no idea what would be useful for that.

jorgenschaefer avatar Mar 10 '17 22:03 jorgenschaefer

Likely not too many usecases for a general-purpose python user, but for the scipy/numpy crowd, it's very useful for visualization. You might have a code chunk that generates a graph or chart or whatnot that lives in the same file as a large amount of dataprocessing. You don't want to wait for a minute every time you update a particular graph, nor do you want to generate multiple graphs every time you want to re-visualize a certain one.

I'll likely implement this myself, and file a pull request. If in the meantime you feel it's not suitable for this project, then no hard feelings if you decide to dismiss it :)

dwcoates avatar Mar 11 '17 01:03 dwcoates

maybe late here, but there is a package for that: https://github.com/wavexx/python-x.el

Lompik avatar Apr 29 '17 13:04 Lompik

Ah, cool. I ended up implementing this, but was rude and didn't file a pull request. I'll try to get around to that within the next couple of days

dwcoates avatar May 03 '17 00:05 dwcoates

@dwcoates are you still planning to file the PR? I would be glad to help with review and testing.

fleimgruber avatar Jun 05 '17 16:06 fleimgruber

Yes I'll get to it soon (just kidding)

dwcoates avatar Jul 05 '25 01:07 dwcoates

What a blast from the past! I see you are also playing around with MCP, so let Claude do it (also kidding)

fleimgruber avatar Jul 05 '25 09:07 fleimgruber