Skip to content
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

keep cursor in code buffer #134

Closed
mankoff opened this issue Oct 1, 2013 · 2 comments
Closed

keep cursor in code buffer #134

mankoff opened this issue Oct 1, 2013 · 2 comments
Labels
Milestone

Comments

@mankoff
Copy link

mankoff commented Oct 1, 2013

C-c C-c executes code buffer but moves cursor to IPython buffer. Is there a way to keep the cursor in the code buffer?

@jorgenschaefer
Copy link
Owner

Not by default, but you can redefine elpy-shell-send-region-or-buffer and simply omit the last line:

(defun elpy-shell-send-region-or-buffer (&optional arg)
  "Send the active region or the buffer to the Python shell.                    

If there is an active region, send that. Otherwise, send the                    
whole buffer.                                                                   

Without prefix argument, this will escape the Python idiom of                   
if __name__ == '__main__' to be false to avoid accidental                       
execution of code. With prefix argument, this code is executed."
  (interactive "P")
  ;; Ensure process exists                                                      
  (elpy-shell-get-or-create-process)
  (if (region-active-p)
      (python-shell-send-region (region-beginning)
                                (region-end))
    (python-shell-send-buffer arg)))

@mankoff
Copy link
Author

mankoff commented Oct 1, 2013

Works great. Thank you. Feel free to re-open as feature request to make this an option, but I'm good with this solution.

@mankoff mankoff closed this as completed Oct 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants