Skip to content

Commit

Permalink
Override indent-tabs-mode for code sent to Python.
Browse files Browse the repository at this point in the history
It was possible that a globally configured indent-tabs-mode would
cause tabs to be inserted into code before it was sent to a Python
shell, confusing the interpreter. We now override the variable with
a correct local default.

Tabs are evil.

Fixes #499
  • Loading branch information
jorgenschaefer committed Aug 22, 2015
1 parent 52e33e9 commit e305783
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion elpy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,8 @@ code is executed."
(if (= beg end)
""
(let ((region (buffer-substring beg end))
(indent-level nil))
(indent-level nil)
(indent-tabs-mode nil))
(with-temp-buffer
(insert region)
(goto-char (point-min))
Expand Down
11 changes: 10 additions & 1 deletion test/elpy-shell--region-without-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@
"\n"
"meh\n")
(should-error (elpy-shell--region-without-indentation (point-min)
(point-max))))))
(point-max))))

(with-temp-buffer
(insert "if True:\n"
" if True:\n"
" pass\n")
(should (equal (let ((indent-tabs-mode t))
(elpy-shell--region-without-indentation (point-min)
(point-max)))
(buffer-string))))))

0 comments on commit e305783

Please sign in to comment.