在Emacs的双引号之间改变纯文本的面 [英] Change face of plain text between double quotation marks in Emacs

查看:191
本文介绍了在Emacs的双引号之间改变纯文本的面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种以纯文本突出显示或使用引用文本的不同面孔的方法。似乎应该有一个复杂/增强的文本模式,但我找不到它。

I am looking for a way to highlight or use different face of quoted text in plain text. It seems that there should be a sophisticated/enhanced text mode but I cannot find it.

如果没有一个简单的解决方案,可以让我知道我应该在哪里开始编写一个函数?

If there isn't a easy solution, can you let me know where should I begin to write a function?

非常感谢!

从19.xx开始使用Emacs的人物

A noob who has been using Emacs from 19.xx

推荐答案

我不知道已经做到这一点的主要模式,但是您可以使用define-derived-mode轻松使用

I'm not sure about a major-mode that already does this, but you can make one easily enough using define-derived-mode

(define-derived-mode rich-text-mode text-mode "Rich Text"
  "text mode with string highlighting."

  ;;register keywords
  (setq rich-text-font-lock-keywords
        '(("\"\\(\\(?:.\\|\n\\)*?[^\\]\\)\"" 0 font-lock-string-face)))
  (setq font-lock-defaults rich-text-font-lock-keywords)
  (font-lock-mode 1))

或者,你可以为文本模式添加一个钩子:

Alternatively, you can add a hook to text-mode:

(defun add-quotes-to-font-lock-keywords ()
  (font-lock-add-keywords nil '(("\"\\(\\(?:.\\|\n\\)*?[^\\]\\)\"" 0 font-lock-string-face))))

(add-hook 'text-mode-hook 'add-quotes-to-font-lock-keywords)

一般来说,编辑任何文字的好方式是组织模式。默认情况下,它不会字体锁定字符串。

Generally speaking, a good mode for editing any text is org-mode. It does not font-lock strings by default, though.

这篇关于在Emacs的双引号之间改变纯文本的面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆