Skip to content

Commit

Permalink
Switch between Python buffer and shell
Browse files Browse the repository at this point in the history
Bind C-c C-z in Python shells to switch back to the recent Python buffer
  • Loading branch information
Anand committed May 18, 2015
1 parent c422b57 commit 9cd3c29
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions elpy.el
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ edited instead. Setting this variable to nil disables this feature."
;; (define-key map (kbd "C-c <") 'python-indent-shift-left)
;; (define-key map (kbd "C-c >") 'python-indent-shift-right)
(define-key map (kbd "C-c C-c") 'elpy-shell-send-region-or-buffer)
(define-key map (kbd "C-c C-z") 'elpy-shell-switch-to-shell)
(define-key map (kbd "C-c C-d") 'elpy-doc)
(define-key map (kbd "C-c C-e") 'elpy-multiedit-python-symbol-at-point)
(define-key map (kbd "C-c C-f") 'elpy-find-file)
Expand All @@ -323,7 +322,7 @@ edited instead. Setting this variable to nil disables this feature."
(define-key map (kbd "C-c C-s") 'elpy-rgrep-symbol)
(define-key map (kbd "C-c C-t") 'elpy-test)
(define-key map (kbd "C-c C-v") 'elpy-check)
;; (define-key map (kbd "C-c C-z") 'python-shell-switch-to-shell)
(define-key map (kbd "C-c C-z") 'elpy-shell-switch-to-shell)

(define-key map (kbd "<S-return>") 'elpy-open-and-indent-line-below)
(define-key map (kbd "<C-S-return>") 'elpy-open-and-indent-line-above)
Expand Down Expand Up @@ -422,6 +421,7 @@ edited instead. Setting this variable to nil disables this feature."
"Elpy only works with python.el from "
"Emacs 24 and above"))))
(elpy-modules-global-init)
(define-key inferior-python-mode-map (kbd "C-c C-z") 'elpy-shell-switch-to-buffer)
(add-hook 'python-mode-hook 'elpy-mode))

(defun elpy-disable ()
Expand Down Expand Up @@ -1453,6 +1453,11 @@ code is executed."
(interactive)
(pop-to-buffer (process-buffer (elpy-shell-get-or-create-process))))

(defun elpy-shell-switch-to-buffer ()
"Switch from inferior Python process buffer to recent Python buffer."
(interactive)
(pop-to-buffer (other-buffer (current-buffer) 1)))

(defun elpy-shell-get-or-create-process ()
"Get or create an inferior Python process for current buffer and return it."
(let* ((bufname (format "*%s*" (python-shell-get-process-name nil)))
Expand Down

0 comments on commit 9cd3c29

Please sign in to comment.