在 Emacs 中更改双引号之间的纯文本外观
我正在寻找一种方法来突出显示或使用纯文本中引用文本的不同面。似乎应该有一个复杂/增强的文本模式,但我找不到它。
如果没有简单的解决方案,您能让我知道我应该从哪里开始编写函数吗?
非常感谢!
一个从 19.xx 开始使用 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?
Thank you very much!
A noob who has been using Emacs from 19.xx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定是否有一个主要模式已经做到了这一点,但是您可以使用define-driven-mode轻松制作一个模式
或者,您可以向文本模式添加一个钩子:
一般来说,这是一种编辑任何文本的好模式是组织模式。但默认情况下它不会锁定字符串的字体。
I'm not sure about a major-mode that already does this, but you can make one easily enough using define-derived-mode
Alternatively, you can add a hook to text-mode:
Generally speaking, a good mode for editing any text is org-mode. It does not font-lock strings by default, though.
对于正则表达式,我认为您希望在字符串内容中排除
"
本身,除非转义。像这样 ---"
,后跟非"
或转义字符,后跟"
:但请注意,匹配引号“...”是臭名昭著的。我在 Info+ 中正是这样做的,但有一些信息节点的突出显示会被引用此类编程结构的手册中偶尔出现的单独的
\"
或?\"
所影响。For the regexp, I think you want to exclude
"
itself in the string content, except when escaped. Something like this ---"
, followed by either a non"
or an escaped character, followed by"
:But be aware that matching quotations "..." is notorious. I do exactly that in Info+, but there are a few Info nodes where this highlighting gets thrown off by the occasional lone
\"
or?\"
in manuals that refer to such programming constructs.