【发布时间】:2013-08-09 22:50:48
【问题描述】:
我拼命尝试让我的 emacs xml (sgml?) 模式使用制表符而不是空格缩进。 到目前为止我尝试了什么:
(defun my-xml-hook ()
(setq c-tab-always-indent t
tab-width 4
indent-tabs-mode t) ; use tabs for indentation
(setq indent-line-function 'insert-tab)
)
(add-hook 'xml-mode-hook 'my-xml-hook)
(defun local-sgml-mode-hook
(setq fill-column 70
indent-tabs-mode t
next-line-add-newlines nil
sgml-indent-data t)
(auto-fill-mode t)
(setq indent-line-function 'insert-tab)
)
(add-hook 'psgml-mode-hook '(lambda () (local-psgml-mode-hook)))
虽然没有任何效果,但在编辑 *.xml 文件时,缩进仍然会出现 2 个空格(emacs23 和 emacs24)。
注意我也有
(setq indent-tabs-mode nil)
在我的 .emacs 文件中,但是应该在之后调用钩子,因此应该覆盖它。
如何强制 emacs 使用 *.xml 文件中的制表符缩进?为什么我的钩子不起作用?
【问题讨论】:
-
c-tab-always-indent用于 C/C++/Java。由于 xml 不继承它们,我认为它不会起作用 -
你应该使用等效的
tab-always-indentvar -
@abo-abo: tab-always-indent 在点击 tab 时总是会插入一个 tab。但是,我希望 auto-indentation 使用制表符,这样如果缩进已经正确并且我点击了 TAB,则什么也不会发生。对于手动插入标签,我总是可以使用 C-q TAB。
标签: xml emacs indentation sgml