emacs中tab转空格有问题,请大神帮忙

sanzhong104204 2015-03-06 11:49:58
问题是这样的,我在~/.emacs里配置了如下所示的禁止使用tab的选项,
;; translate [tab] to spaces
(setq-default indent-tabs-mode 0)
(setq tab-width 4)
(setq c-default-style "linux")
(setq c-basic-offset 4)
可是在我编写C语言代码时,发现main函数里的语句前面的tab确实成功用空格代替了,但是if(){}块中的代码前面却还是tab键,并未替换成空格。有没有哪位大神能帮帮忙?
1int main()
2{
3 int i ;
4 int j;
5 if(xx)
6 {
7 xx;
8 xx;
9 }
10}
完整的~/.emacs文件:


;; color setup
(set-background-color "black")
(set-foreground-color "white")
(set-face-foreground 'region "green")
(set-face-background 'region "blue")

;;line number on the left of buffer
(global-linum-mode 'linum-mode)

;; transient mark mode is used to highlight region we select
(setq transient-mark-mode t)
;; hide tool bar
(tool-bar-mode 0)

;; syntax highlight
(global-font-lock-mode t)
;;(setq default-major-mode 'text-mode)
;;(global-hi-lock-mode 1)
(setq hi-lock-file-patterns-policy #'(lambda (dummy) t))

;; use mouse even in terminal
;;(xterm-mouse-mode t)
;; enable wheel on mouse
(mouse-wheel-mode t)

;; setup mouse wheel
(defun up-sightly () (interactive) (scroll-up 3))
(defun down-sightly () (interactive) (scroll-down 3))

;; no #F# files
(setq auto-save-default 0)

;; auto-backup enable
(setq backup-by-copying t)
;; save auto-backup files into dir "~/.saves"
(setq backup-directory-alist '(("." . "~/.saves")))
;; delete-old-versions automatically
(setq delete-old-versions t)
;; keep last 6 newest versions
(setq kept-new-versions 6)
;; keep the 2 oldest versions
(setq kept-old-versions 2)
;; enable version-control on backup files
(setq version-control t)

;; translate [tab] to spaces
(setq-default indent-tabs-mode 0)
(setq tab-width 4)
;; c-coding-style reference to webpage http://www.emacswiki.org/emacs/IndentingC
(setq c-default-style "linux")
(setq c-basic-offset 4)

;; UTF-8 settings
(set-language-environment "UTF-8")
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(modify-coding-system-alist 'process "*" 'utf-8)

;;(add-hook 'c-mode-hook
;;'(lambda ()
;;(c-set-style "linux")
;;(c-toggle-hungry-state)
;;(setq c-basic-offset 4)
;;(imenu-add-menubar-index)
;;(which-function-mode)))

;;(add-hook 'c++-mode-hook
;;'(lambda()
;;(c-set-style "k&r")
;;(c-toggle-auto-state)
;;(c-toggle-hungry-state)
;;(setq c-basic-offset 4)
;;(imenu-add-menubar-index)
;;(which-function-mode)))

(custom-set-variables
'(load-home-init-file t t))
(custom-set-faces)



emacs版本信息:
[qunfeng@thinkpad 11:45:46 src]$ emacs --version
GNU Emacs 24.3.1
Copyright (C) 2013 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
[qunfeng@thinkpad 11:45:51 src]$
系统版本信息:
[qunfeng@thinkpad 11:46:28 src]$ cat /proc/version
Linux version 3.13.0-24-generic (buildd@roseapple) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014
[qunfeng@thinkpad 11:47:04 src]$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
[qunfeng@thinkpad 11:47:45 src]$
...全文
174 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

18,773

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧