如何为主模式定义注释语法?

时间:2014-08-20 08:41:28

标签: emacs comments dot-emacs

我想将评论添加到我目前不支持的主要模式。我可以在网上找到的唯一示例显示了如何编写single-line comments,但我需要成对的分隔符。

我需要改变什么?

1 个答案:

答案 0 :(得分:1)

我最终深入研究了我正在使用的软件包。问题是,如果你添加

(setq comment-start "FOO")
(setq comment-end "BAR")

your-mode-hook,然后,当您切换到另一种定义comment-start但不是comment-end的语言时,最终会导致comment-end坚持使用其他模式。例如,您的python-mode条评论如下:

# def my_func(): BAR

绝对不是你想要的。要解决此问题,请使用以下命令:

(add-hook 'your-mode-hook
          (lambda ()
            (set (make-local-variable 'comment-start) "FOO")
            (set (make-local-variable 'comment-end) "BAR")))

并且它不会破坏其他模式'comment-end

相关问题