我设置(setq default-tab-width 4) (c-basic-offset 4)都不好用。
没办法,加了一个(c-tab-always-indent . t)
现在是好用了,可是原来对于C源码的自动缩排不能使用了,不知道谁有什么好的办法能搞定这个么?先谢啦
我猜测可能那个indent的原因,下面是在.emacs中相关设置:
(require 'doxymacs) ;; 启动doxymacs
(add-hook 'c-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode
(add-hook 'c++-mode-common-hook 'doxymacs-mode) ;; 启动doxymacs-mode
(add-hook 'c-mode-common-hook ( lambda() ( c-set-style "k&r" ) ) ) ;;设置C语言默认格式
(add-hook 'c++-mode-common-hook ( lambda() ( c-set-style "stroustrup" ) ) )
;;设置C++语言默认格式
;;CC-mode http://cc-mode.sourceforge.net/
(require 'cc-mode)
(c-set-offset 'inline-open 0)
(c-set-offset 'friend '-)
(c-set-offset 'substatement-open 0)
;;hippie的自动补齐策略,优先调用了senator的分析结果
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-semantic
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-expand-list
try-expand-list-all-buffers
try-expand-line
try-expand-line-all-buffers
try-complete-file-name-partially
try-complete-file-name
try-expand-whole-kill
)
)
(setq default-tab-width 4)
;;(setq tab-stop-list ())
;;(loop for x downfrom 40 to 1 do
;; (setq tab-stop-list (cons (* x 4) tab-stop-list)))
;;C/C++语言编辑策略
(defun my-c-mode-common-hook()
(c-tab-always-indent . t)
;; (c-comment-only-line-offset . 4)
(setq tab-width 4 indent-tabs-mode nil)
(setq c-basic-offset tab-width)
;;; 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)] '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)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;预处理设置
(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)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
--
E.L will be the K.
|