Skip to content

Commit

Permalink
python: really start REPL also in emacs 25.1
Browse files Browse the repository at this point in the history
Make `python-start-or-switch-repl` start a REPL when necessery also in
Emacs 25.1. Previously in Emacs 25.1 it wouldn't do anything if the REPL
wasn't started already.
  • Loading branch information
bmag authored and syl20bnr committed Oct 19, 2016
1 parent 63766ba commit 71ac62c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions layers/+lang/python/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,22 @@
(defun python-start-or-switch-repl ()
"Start and/or switch to the REPL."
(interactive)
(python-shell-switch-to-shell)
(evil-insert-state))
(let ((shell-process
(or (python-shell-get-process)
;; `run-python' has different return values and different
;; errors in different emacs versions. In 24.4, it throws an
;; error when the process didn't start, but in 25.1 it
;; doesn't throw an error, so we demote errors here and
;; check the process later
(with-demoted-errors "Error: %S"
;; in Emacs 24.5 and 24.4, `run-python' doesn't return the
;; shell process
(call-interactively #'run-python)
(python-shell-get-process)))))
(unless shell-process
(error "Failed to start python shell properly"))
(pop-to-buffer (process-buffer shell-process))
(evil-insert-state)))

(defun spacemacs/python-execute-file (arg)
"Execute a python script in a shell."
Expand Down

0 comments on commit 71ac62c

Please sign in to comment.