Skip to content

Commit

Permalink
Use new convention for python shell name
Browse files Browse the repository at this point in the history
The name of the dedicated python shells are now using the buffer name
without extension.
This avoid conflicts with the way python.el handles dedicated shells
(see jorgenschaefer#1328).
  • Loading branch information
galaunay committed Apr 20, 2018
1 parent 63263c3 commit 3a78e61
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions elpy-shell.el
Expand Up @@ -256,7 +256,9 @@ if ARG is negative or 0, disable the use of a dedicated shell."
(if (<= arg 0)
(kill-local-variable 'python-shell-buffer-name)
(setq-local python-shell-buffer-name
(format "Python[%s]" (buffer-name))))))
(format "Python[%s]"
(file-name-sans-extension
(buffer-name)))))))

(defun elpy-shell-set-local-shell (&optional shell-name)
"Associate the current buffer to a specific shell.
Expand All @@ -276,12 +278,14 @@ shell (often \"*Python*\" shell)."
"Global"))
(shell-names (cl-loop
for buffer in (buffer-list)
for buffer-name = (substring-no-properties (buffer-name buffer))
for buffer-name = (file-name-sans-extension (substring-no-properties (buffer-name buffer)))
if (string-match "\\*Python\\[\\(.*?\\)\\]\\*" buffer-name)
collect (match-string 1 buffer-name)))
(candidates (remove current-shell-name
(delete-dups
(append (list (buffer-name) "Global") shell-names))))
(delete-dups
(append (list (file-name-sans-extension
(buffer-name)) "Global")
shell-names))))
(prompt (format "Shell name (current: %s): " current-shell-name))
(shell-name (or shell-name (completing-read prompt candidates))))
(if (string= shell-name "Global")
Expand Down

0 comments on commit 3a78e61

Please sign in to comment.