python-mode: fix indent offset guessing for tab indentation

This commit is contained in:
Benno Fünfstück 2018-08-25 14:29:51 +02:00 committed by Codruț Constantin Gușoi
parent 35b258cd51
commit f31bed7f52
3 changed files with 11 additions and 0 deletions

View file

@ -33,6 +33,9 @@ and `lsp'.")
(defvar python-tab-width 4
"Tab width value for python buffers")
(defvar python-spacemacs-indent-guess t
"If non-nil, try to guess correct indentation settings for python buffers on opening")
(defvar python-auto-set-local-pyenv-version 'on-visit
"Automatically set pyenv version from \".python-version\".

View file

@ -91,6 +91,11 @@ when this mode is enabled since the minibuffer is cleared all the time."
(setq mode-name "Python"
tab-width python-tab-width
fill-column python-fill-column)
;; since we changed the tab-width we need to manually cally python-indent-guess-inden-offset herr
(when python-spacemacs-indent-guess
(python-indent-guess-indent-offset))
(when (version< emacs-version "24.5")
;; auto-indent on colon doesn't work well with if statement
;; should be fixed in 24.5 and above

View file

@ -334,6 +334,9 @@
"sR" 'spacemacs/python-shell-send-region-switch
"sr" 'python-shell-send-region)
;; we call python-indent-guess-indent-offset ourselves so set to nil to avoid duplicate work
(setq-default python-indent-guess-indent-offset nil)
;; Emacs users won't need these key bindings
;; TODO: make these key bindings dynamic given the current style
;; Doing it only at init time won't update it if the user switches style