2008年12月23日星期二

emacs 下tab 变空格

    By default, Emacs inserts tabs in place of multiple spaces when it formats a region. (For example, you might indent many lines of text all at once with the indent-region command.) Tabs look fine on a terminal or with ordinary printing, but they produce badly indented output when you use TeX or Texinfo since TeX ignores tabs.

The following turns off Indent Tabs mode:

;;; Prevent Extraneous Tabs
(setq-default indent-tabs-mode nil)
Note that this line uses setq-default rather than the setq command that we have seen before. The setq-default command sets values only in buffers that do not have their own local values for the variable.

在php下我想按此进行设置..

照方抓药,通常来讲 (setq-default indent-tabs-mode nil), 这样设置就ok.
按此方法,依然无效. 仔细看过以前的配置, 原来是以前 抄来的配置中的问题
(defun my-c-common-hook()
(setq tab-width 4)
(define-key c++-mode-map "\C-m" 'reindent-then-newline-and-indent)
(define-key c++-mode-map "\C-ce" 'c-comment-edit)
;; (setq c++-auto-hungry-initial-state 'none)
(setq c++-delete-function 'backward-delete-char)
(setq c++-tab-always-indent t)
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq compile-command "make"))
(add-hook 'c-mode-common-hook 'my-c-common-hook)

php-mode 是依赖c-mode-common-hook 的, 在上段配置中的设置如下 (setq tab-width 4),按照默认 tab是生效的,把 (setq-default indent-tabs-mode nil) 给覆盖了. 因此在php-mode 下依然失效. 改为 (setq tab-width 4 indent-tabs-mode nil) 一切ok

没有评论: