Чтобы получить отступ, который вам нравится, используйте такие методы отладки:
(setq c-echo-syntactic-information-p t)
Когда вы нажимаете TAB для отступа, вы увидите что-то вроде:
syntax: ((inclass 33) (access-label 33))
КакВы можете видеть метка доступа , идентифицирующая отступ модификаторов priv / pub.Поэтому измените на то, что вы хотите:
(defconst my-c-style
'(
(c-tab-always-indent . t)
(c-offsets-alist
. (
(access-label . /) ; XXXXXX LOOK HERE!!!!!!!
))
)
"My C Programming Style")
(defun my-c-mode-style-hook ()
(c-add-style "my" my-c-style t)
;; If set 'c-default-style' before 'c-add-style'
;; "Undefined style: my" error occured from 'c-get-style-variables'.
(setq c-default-style
'(
(java-mode . "my") (c-mode . "my") (csharp-mode . "my") (c++-mode . "my")
(other . "my")
))
)
(add-hook 'c-mode-common-hook 'my-c-mode-style-hook)
В примере я удаляю отступ на половину уровня как inclass добавляем один полный отступ (чтобы получить 1/2 отступа. Для синтаксиса смещения читайте Ch v c-offsets-alist RET . Например:
If OFFSET is one of the symbols `+', `-', `++', `--', `*', or `/'
then a positive or negative multiple of `c-basic-offset' is added to
the base indentation; 1, -1, 2, -2, 0.5, and -0.5, respectively.