gpt4 book ai didi

python - 为什么我在 Emacs 中得到了太多的标签?

转载 作者:太空宇宙 更新时间:2023-11-03 11:56:42 25 4
gpt4 key购买 nike

初始化.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键。

关于python - 为什么我在 Emacs 中得到了太多的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7086940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com