Почему я получаю слишком много вкладок в Emacs? - PullRequest
4 голосов
/ 17 августа 2011

init.el

(setq make-backup-files nil)

(add-to-list 'load-path "~/.emacs.d/")

; Add all top-level subdirectories of .emacs.d to the load path
(progn (cd "~/.emacs.d")
       (normal-top-level-add-subdirs-to-load-path))
; Third party libraries are stored in ~/.emacs.d/extern
(add-to-list 'load-path "~/.emacs.d/extern")
(progn (cd "~/.emacs.d/extern")
       (normal-top-level-add-subdirs-to-load-path))

; Python-specific enchancements
(load-library "python")

; Zenburn color theme
(require 'color-theme-zenburn)

(color-theme-zenburn)

python.el

; use tabs in files (urgh...yelp!)
;(setq-default indent-tabs-mode t)

; tab display width of 4 columns by default
; (throw everything at the wall, and eventually something will stick...)
;(setq-default tab-width 4)  ; Normal emacs tab-width
; (setq-default c-basic-offset 2) ; python-mode.el setting
;(setq-default py-indent-offset 4) ; Use Tabs, not spaces
;(setq-default py-smart-indentation nil) ; Don't try to guess tab width

(defun customize-py-tabs ()
    (setq tab-width 4
        py-indent-offset 4
        indent-tabs-mode t
        py-smart-indentation nil
   )
)

(add-hook 'python-mode-hook 'customize-py-tabs)

; Highlight useless whitespace
(add-hook 'python-mode-hook
                  (lambda () (setq show-trailing-whitespace t)))

Я пытаюсь настроить мой emacs для перехода на правильный уровень в моем коде python, но это добавляет дополнительную вкладку. Это постоянное. Если должно быть 4 вкладки, я получаю 5. Любые предложения?

например

def func:
        # This is where it puts me
    # This is where it SHOULD put be

Ответы [ 2 ]

1 голос
/ 06 апреля 2012

Любые отступы Python, начинающиеся с установки tab-width на значение, отличное от 8, обречены на неприятности. tab-width определяет, как Emacs отображает символ TAB, а не как далеко для отступа в ответ на нажатие клавиши tab.

0 голосов
/ 17 августа 2011

Может быть, вам не нужно решать эту проблему. Руководство по стилю для кода Python настоятельно рекомендует использовать 4 пробела, почему бы не следовать им?

...