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
解决方法:
任何以将tab-width设置为8以外的其他Python缩进都注定会带来麻烦. tab-width确定Emacs如何显示TAB字符,而不是在响应按Tab键时缩进的距离.