我无法让 Emacs 运行并将 Python(或任何环境)设置为 4 空格制表符。以下是我的.emacs
文件,我已经尝试了 下的所有选项;; --- Set python indent to 4 spaces ---
,但都没有奏效。缩进是否可能发生一些冲突或覆盖?
此外,无论我将制表符列表变量设置为 4 的倍数多少次,当我从菜单中使用“自定义 Emacs”并在 .emacs 文件中设置变量时,它们总是以 8 的倍数结束。
我正在为 Mac OS X ( http://emacsformacosx.com/ ) 使用 GNU emacs。
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
'(custom-enabled-themes (quote (deeper-blue)))
'(indent-tabs-mode nil)
'(inhibit-startup-screen t)
'(python-guess-indent nil)
'(python-honour-comment-indentation t)
'(python-use-skeletons t)
'(speedbar-indentation-width 2)
'(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :stipple nil :background "#181a26" :foreground "gray80" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :family "consolas"))))
'(bold ((t (:foreground "white" :weight bold))))
'(variable-pitch ((t (:family "Helvetica Neue")))))
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")
(let (el-get-master-branch)
(goto-char (point-max))
(eval-print-last-sexp))))
(el-get 'sync)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
;; Yet another snippet extension for emacs -------------------------------------
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
;; Develop and keep personal snippets under ~/emacs.d/mysnippets
(setq yas/root-directory "~/.emacs.d/mysnippets")
;; Load the snippets
(yas-load-directory yas/root-directory)
;; Auto headers for files ---------------------------------------------------
(add-to-list 'load-path "~/.emacs.d/plugins/")
(require 'header2)
(add-hook 'emacs-lisp-mode-hook 'auto-make-header)
;; Invoke Emacs Speaks Statistics (ESS) for R
(require 'ess-site)
; automatically get the correct mode
auto-mode-alist (append (list '("\\.c$" . c-mode)
'("\\.tex$" . latex-mode)
'("\\.S$" . S-mode)
'("\\.s$" . S-mode)
'("\\.R$" . R-mode)
'("\\.r$" . R-mode)
'("\\.html$" . html-mode)
'("\\.emacs" . emacs-lisp-mode)
)
auto-mode-alist)
;; --- Automatically close all parens and quotes ---
(add-to-list 'load-path "~/.emacs.d/plugins/autopair")
(require 'autopair)
(autopair-global-mode) ;; enable autopair in all buffers
; Match Triple-quoting in python
(add-hook 'python-mode-hook
#'(lambda ()
(setq autopair-handle-action-fns
(list #'autopair-default-handle-action
#'autopair-python-triple-quote-action))))
;; --- Add autopairing of $ in latex ---
(add-hook 'latex-mode-hook
#'(lambda ()
(push '(?$ . ?$)
(getf autopair-extra-pairs :string))))
; Show column numbers
(setq column-number-mode t)
; --- Set python indent to 4 spaces ---
;; Set indent size to 4
(setq standard-indent 4)
(setq default-tab-width 4)
;; (add-hook 'python-mode-hook '(lambda ()
;; (setq python-indent 4)))
;; (setq-default py-indent-offset 4)
;; (setq indent-tabs-mode t
;; tab-width 4
;; python-indent 4)
;; Python Hook
;; (add-hook 'python-mode-hook
;; (function (lambda ()
;; (setq indent-tabs-mode nil
;; tab-width 4))))
;; --- Remove all tabs, convert them to spaces ---
(setq indent-tabs-mode nil)
;; --- Auto complete latex ---