C++mode 里面 insert 模式下输入单引号会自动变成 \'\'

spacemacs采用的是c++layer clang补全,其他配置没做改动。

GNU Emacs 26.1 Spacemacs 0.200.13.x

descirbe-key:

’ runs the command self-insert-command (found in global-map), which is an interactive built-in function in ‘C source code’.

It is bound to many ordinary text characters.

(self-insert-command N)

Insert the character you type. Whichever character you type to run this command is inserted. The numeric prefix argument N says how many times to repeat the insertion. Before insertion, ‘expand-abbrev’ is executed if the inserted character does not have word syntax and the previous character in the buffer does. After insertion, ‘internal-auto-fill’ is called if ‘auto-fill-function’ is non-nil and if the ‘auto-fill-chars’ table has a non-nil value for the inserted character. At the end, it runs ‘post-self-insert-hook’.

似乎问题出在加粗的一段,但我不太懂elisp(基本语法了解)所以不会排查,能给点建议吗?

如果你有用到 smartparens 这个包,试试:

(if (version< "26.0" emacs-version)
        (setq sp-escape-quotes-after-insert nil))

相关主题:spacemacs c/c++ mode 键入单引号时, 输出为 \'\' - #3,来自 twlz0ne

1 个赞

谢谢啦,这个方法有效~