LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1744|回复: 3

emacs里究竟怎样设置缩进的宽度?

[复制链接]
发表于 2006-9-26 23:19:04 | 显示全部楼层 |阅读模式
[PHP](defun my-c-mode-common-hook()
  (setq tab-width 4 indent-tabs-mode nil)
  ;;; hungry-delete and auto-newline
  (c-toggle-auto-hungry-state 1)
  ;;按键定义
  (define-key c-mode-base-map [(control \`)] 'hs-toggle-hiding)
  (define-key c-mode-base-map [(return)] 'newline-and-indent)
  (define-key c-mode-base-map [(f7)] 'smart-compile)
  (define-key c-mode-base-map [(meta \`)] 'c-indent-command)
;;  (define-key c-mode-base-map [(tab)] 'hippie-expand)
  (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
  (local-set-key (kbd "{") 'skeleton-c-mode-left-brace)
  ;;(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;; set linux style as the default style. Add by Leon.
  (c-set-style "linux")
;;预处理设置
  (setq c-macro-shrink-window-flag t)
  (setq c-macro-preprocessor "cpp")
  (setq c-macro-cppflags " ")
  (setq c-macro-prompt-flag t)
  (setq hs-minor-mode t)
  (setq abbrev-mode t)
)[/PHP]
这是我的c common hook,我在其它地方还加了
[PHP](setq default-tab-width 4)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)[/PHP]这样的语句,可是indent的时候还是空8格,怎样才能搞成4格?
我是cvs的emacs,以前的版本好像是好的,真是奇怪
发表于 2006-9-27 11:53:41 | 显示全部楼层
my-indent-or-complete 函数是怎么写的?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-27 23:18:43 | 显示全部楼层
(defun my-indent-or-complete ()
  (interactive)
  (if (looking-at "\\>")
      (hippie-expand nil)
    (indent-for-tab-command))
  )
从别人那边抄来的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-27 23:20:24 | 显示全部楼层
搜了好久,终于找到了,只要在my-c-mode-common-hook中加人
(setq c-basic-offset 4)
就可以了,原来以为缩进的宽度是由tabs-width控制的呢,看来是误解:)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表