Closed dgopstein closed 7 years ago
Any particular binding we should use?
Perhaps it would be prudent to follow the precedent set by ESS which uses C-c C-j
for eval-line
.
If this works for you, I'd be glad to send over a PR.
Incidentally, ESS also has a couple popular keybindings for eval-line-and-step
and eval-region-or-line-and-step
, which executes the current line (and sometimes a region, if selected) then advances the cursor one line. Those are bound to C-c C-n
and C-<ret>
respectively. Do you think there'd be value in adding these as well, or too much bloat?
I wonder if the ruby-send-definition which is bound to C-M-x can be smart enough to detect that it's a single line that it needs to send (to make the editing experience more lisp-like)?
For example I have a line like this: arr = Array.new(100) { rand(1...100) }
I would expect either ruby-send-last-sexp (C-x C-e) with the cursor at the end of line or ruby-send-definition (C-M-x) with the cursor anywhere in the line to work. Both of those options give me an error.
arr = Array.new(100) { rand(1...100) }
But that's not a defun (even in Lisp terms), and the "last sexp" here is { rand(1...100) }
. We could conceivably fix ruby-mode so that the last sexp here will be Array.new(100) { rand(1...100) }
. But probably not arr = Array.new(100) { rand(1...100) }
.
Although if you'd like to discuss that possibility, feel free to M-x report-emacs-bug
that backward-sexp
doesn't jump over the whole assignment. Maybe Stefan will have something to add.
ruby-send-line
has been added, BTW. Just without any default binding.
To send the contents of the current line to the repl.
While the functionality is achievable with
ruby-send-region
a dedicated implementation would be much more convenient.Possible implementation: