我最近开始使用Emacs,我一直面临的一个问题是编辑器会自动将所有的制表符转换为空格。现在已经开始变得有点烦人了。
下面是我的.emacs文件以供参考:
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(custom-set-variables
'(custom-enabled-themes (quote (dracula)))
'(custom-safe-themes)
'(display-line-numbers-type (quote relative))
'(global-display-line-numbers-mode t)
'(menu-bar-mode nil)
'(package-selected-packages
(quote
(company-irony-c-headers company-irony micgoline elpy company-jedi molokai-theme gruvbox-theme autopair auto-complete anaconda-mode nyan-mode dracula-theme company)))
'(scroll-bar-mode nil)
'(tool-bar-mode nil))
(custom-set-faces
)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq inhibit-startup-message t) ;; hide the startup message
(elpy-enable)
(pyenv-mode)
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt")
(require 'powerline)对于如何阻止emacs执行此操作,有什么建议吗?
发布于 2020-01-30 00:12:48
根据Drew的建议,我将此作为答案发布:
你检查变量indent-tabs-mode了吗?
这样,您应该能够使用空格或制表符在emacs之间切换。
正如我在emacs wiki here中所描述的,一些活动模式在您的emacs中将其设置为nil。您可以找到另一种解释,其中包含有关选项卡是否是邪恶的here的讨论的链接
编辑:奇怪的是,python模式将indent-tabs-mode设置为t。也许这个Emacs Wiki entry可以解决你的问题。这段来自wiki的代码片段:
(add-hook 'python-mode-hook
(lambda ()
(setq-default indent-tabs-mode t)
(setq-default tab-width 4)
(setq-default py-indent-tabs-mode t)
(add-to-list 'write-file-functions 'delete-trailing-whitespace)))看起来它能起到作用。希望这能有所帮助。
https://stackoverflow.com/questions/59968080
复制相似问题