Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 定制google-c-style.el_C++_Emacs_Indentation - Fatal编程技术网

C++ 定制google-c-style.el

C++ 定制google-c-style.el,c++,emacs,indentation,C++,Emacs,Indentation,我正在缩进我的C++程序。类中的函数将按如下方式缩进: 这不是我想要的,我想要这个: 以下是我在.emacs中的设置: (setq c-default-style“linux”) (setq c-基本-偏移量4) (需要“抄送模式”) (需要“谷歌c风格”) (添加钩子'c-mode-common-hook'谷歌换行缩进) 看起来您还需要: (添加hook'c-mode-common-hook'google-set-c-style) 目前,即使您需要google-c-style,在调用上面的

我正在缩进我的C++程序。类中的函数将按如下方式缩进:

这不是我想要的,我想要这个:

以下是我在.emacs中的设置:

(setq c-default-style“linux”)

(setq c-基本-偏移量4)

(需要“抄送模式”)

(需要“谷歌c风格”)

(添加钩子'c-mode-common-hook'谷歌换行缩进)


看起来您还需要:

(添加hook'c-mode-common-hook'google-set-c-style)

目前,即使您
需要
google-c-style,在调用上面的defun之前,它不会添加样式。文档字符串说它也应该被添加到钩子中


一般来说,对于缩进问题,您需要了解
c-offset-alist

它允许您自定义在不同语法元素上执行缩进的方式。 确定需要修改哪个元素的一个简单方法是转到该位置(例如,示例中的
fun()
的大括号open)并点击C-C-s以查看
C-show-syntactical-information

而不是使用这个谷歌风格的脚本,我个人会从它或另一个c风格派生并覆盖这些值以适合我的口味

例如,我注意到您希望c-basic-offset为4,但google样式使用的c-basic-offset为2,因此您可以从google样式派生并重写它来替换c-basic-offset


签出:例如。

在您的模式下,点击C-C-o Enter更改缩进偏移。