gpt4 book ai didi

emacs - Emacs 单引号字符串中的通用模式被突出显示

转载 作者:行者123 更新时间:2023-12-05 06:33:28 30 4
gpt4 key购买 nike

简单的问题,我在 Emacs 中使用通用模式进行颜色编码。除了在这种语言中 "' 可以用来表示字符串之外,下面的代码很好用,如 'this is a string'“这是一个字符串”。默认情况下,在通用模式下,“突出显示”但“不是”。

(require 'generic-x)

(define-generic-mode
'foo-mode ;; name of the mode to create
'("#") ;; comments start with '!!'
'("for" "if" "else" ) ;; some keywords
'(("=" . 'font-lock-operator) ;; '=' is an operator
("+" . 'font-lock-operator) ;; '=' is an operator
("-" . 'font-lock-operator) ;; '=' is an operator
("'" . 'font-lock-builtin) ;; '=' is an operator
("<-" . 'font-lock-operator) ;; '=' is an operator
("*" . 'font-lock-operator) ;; '=' is an operator
("/" . 'font-lock-operator) ;; '=' is an operator
("," . 'font-lock-builtin) ;; ';' is a built-in
(";" . 'font-lock-builtin)) ;; ';' is a built-in
'("\\.myext$") ;; files for which to activate this mode
nil ;; other functions to call
"A generic mode for myext files" ;; doc string for this mode
)

有没有一种简单的方法可以使上面的 treat 's as "s?

最佳答案

您可能最好听从 Stefans 的建议并使用 define-derived-mode,但由于这个问题是我第一次听说 generic.el,我很好奇并且必须想办法。

在我的测试中,删除 'font-lock-keyword 条目并修改函数中 ' 的语法表条目('(lambda () (modify-syntax-entry ?' "\""))) 在函数列表中似乎有效。

我测试的完整代码:

(define-generic-mode
'foo-mode ;; name of the mode to create
'("#") ;; comments start with '!!'
'("for" "if" "else" ) ;; some keywords
'(("=" . 'font-lock-operator) ;; '=' is an operator
("+" . 'font-lock-operator) ;; '=' is an operator
("-" . 'font-lock-operator) ;; '=' is an operator
("<-" . 'font-lock-operator) ;; '=' is an operator
("*" . 'font-lock-operator) ;; '=' is an operator
("/" . 'font-lock-operator) ;; '=' is an operator
("," . 'font-lock-builtin) ;; ';' is a built-in
(";" . 'font-lock-builtin)) ;; ';' is a built-in
'("\\.myext$") ;; files for which to activate this mode
'((lambda () (modify-syntax-entry ?' "\""))) ;; other functions to call
"A generic mode for myext files" ;; doc string for this mode
)

关于emacs - Emacs 单引号字符串中的通用模式被突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50720451/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com