我正在尝试为Twig创建次要模式,语法与django非常相似,我想更改注释样式的值以使用{#和#}
如果我这样做
(setq comment-start "{#")
(setq comment-end "#}")
正确运行,但当更改为lisp-mode时,注释结尾仍然是“#}”而不是“”
代码为here
由于
答案 0 :(得分:3)
您需要添加以下内容buffer-local
:
(set (make-local-variable 'comment-start) "{#")
(set (make-local-variable 'comment-end) "#}")
到define-minor-mode
身体。
答案 1 :(得分:1)
您可以根据how to change the cursor based on a minor mode上的答案执行某些操作:
(defvar twig-mode-previous-comments nil
"Storage for comment start/end that was before twig mode was enabled")
(define-minor-mode twig-mode "twig" :lighter ""
(unless twig-mode-previous-comments
(set (make-local-variable 'twig-mode-previous-comments) (cons comment-start comment-end)))
(if twig-mode
(progn
(set (make-local-variable 'comment-start) "{#")
(set (make-local-variable 'comment-end) "#}"))
(setq comment-start (car twig-mode-previous-comments))
(setq comment-end (cdr twig-mode-previous-comments))))