emacs python 模式 : how to highlight in different colors a str vs. unicode str

标签 emacs

我希望 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/

相关文章:

emacs - 如何在 Emacs 中将多行从缓冲区复制到另一个缓冲区?

emacs - 如何在 emacs 中显示自动完成选项?

emacs - 将文本拖入在 Emacs 中运行的终端中

variables - 我可以在.dir-locals.el中放入任意的elisp代码吗?

emacs - 如何摆脱 emacs 错误 "void-variable org-format-latex-options"?

emacs - EMACS Mumamo/nxhtml模式正在覆盖js文件的js2-模式

emacs - 当 emacs 以守护进程模式启动时,通过 X11 或终端连接时如何自动加载正确的初始化设置?

emacs - 将 ipynb 笔记本转换为 org 并在 emacs 中执行

emacs - 我的 slime-repl 无法在 ClojureBox 中工作

emacs 组织模式 : folder alias for links in org-files