我希望 emacs 帮助我直观地识别尚未更改为 unicode 字符串的字符串(python 版本 < 3):
"display this string in color red"
和
u"display this string in color orange"
使用 emacs 23 和 python 模式
我需要向我的 .emacs 添加什么?谢谢。
最佳答案
我在 .emacs
中有类似以下内容:
(eval-after-load "python-mode"
(add-hook 'python-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("[^\\w]\\(r\\|u\\)[\'\"]" (1 font-lock-keyword-face)))))))
突出显示 'u' 本身(和 'r'),而不是整个字符串。也许这已经足够了,或者您可以找到一种方法来适应它。
关于emacs python 模式 : how to highlight in different colors a str vs. unicode str,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8664061/