我最终深入研究了我正在使用的包的省略号。问题是如果你添加
(setq comment-start "FOO")
(setq comment-end "BAR")
Run Code Online (Sandbox Code Playgroud)
到your-mode-hook,然后,当您切换到另一种定义comment-start但不定义的语言时comment-end,您最终会坚持comment-end使用另一种模式。例如,您的python-mode评论如下:
# def my_func(): BAR
Run Code Online (Sandbox Code Playgroud)
这绝对不是你想要的。为了解决这个问题,请使用以下命令:
(add-hook 'your-mode-hook
(lambda ()
(set (make-local-variable 'comment-start) "FOO")
(set (make-local-variable 'comment-end) "BAR")))
Run Code Online (Sandbox Code Playgroud)
而且它不会破坏其他模式comment-end。