【发布时间】:2020-03-11 20:17:40
【问题描述】:
我的 .cpp 文件中的所有内容都正常缩进,直到我在以下几行中按下分号 ; --- 此时 emacs 一直缩进到最后一行的全长输入...
如果我删除访问修饰符并为任何类或结构声明 vars int x 和 int y,这很奇怪。
class Blah {
private int x;
private int y;
private int z;
};
如果我突出显示整个字段并按
其他细节:
C-h k ;产生这个描述,所以它可能与这个特性有关——虽然我不明白,因为所描述的缩进似乎是指下一个换行符,而不是光标所在的当前行。
; runs the command c-electric-semi&comma (found in c++-mode-map),
which is an interactive compiled Lisp function in ‘cc-cmds.el’.
It is bound to ,, ;.
(c-electric-semi&comma ARG)
Insert a comma or semicolon.
If ‘c-electric-flag’ is non-nil, point isn’t inside a literal and a
numeric ARG hasn’t been supplied, the command performs several electric
actions:
(a) When the auto-newline feature is turned on (indicated by "/la" on
the mode line) a newline might be inserted. See the variable
‘c-hanging-semi&comma-criteria’ for how newline insertion is determined.
(b) Any auto-newlines are indented. The original line is also
reindented unless ‘c-syntactic-indentation’ is nil.
(c) If auto-newline is turned on, a comma following a brace list or a
semicolon following a defun might be cleaned up, depending on the
settings of ‘c-cleanup-list’.
【问题讨论】:
-
最终发生这种情况是因为您的 C++ 语法错误;
private int x应该是private: int x等 en.cppreference.com/w/cpp/language/access -
该死的谢谢....做了太多的语言切换