如何让 emacs 在字体锁定模式下渲染数学组合字符?
我试图让 emacs 在字体锁定模式下正确渲染数学组合字符,例如分音符、横杠等。目标是能够编写像 x_dot 这样的数学内容并将其显示为“ẋ”,或将 x_bar 显示为“x̄”。
这是我到目前为止所拥有的,而且大部分都有效。
(font-lock-add-keywords
nil
`(("\\<\\(\\w\\)\\(_dot\\)\\>"
(0 (progn (compose-region (match-beginning 1) (match-end 2)
(concatenate 'string (match-string 1) " ̇" )) nil)))))
但是:我在组合角色之前看到了一个视觉伪影角色。执行上述命令后,通过在*scratch*缓冲区中写入“x_dot”或类似的内容来测试这一点。
这件神器像幻影一样来来去去。当组合“o”和“-”等普通字符时,不会发生此行为,如下例所示。
(font-lock-add-keywords
nil
`(("\\<\\(\\w\\)\\(_dash\\)\\>"
(0 (progn (compose-region (match-beginning 1) (match-end 2)
(concatenate 'string (match-string 1) "-" )) nil)))))
然后在某处输入“x_dash”。
到底是怎么回事?
I am trying to get emacs to properly render mathematical combining characters such the diaeresis, over bar, etc in font-lock mode. The goal is to be able to write something mathematical like x_dot and have it be displayed as "ẋ", or x_bar as "x̄".
This is what I have so far, and it mostly works.
(font-lock-add-keywords
nil
`(("\\<\\(\\w\\)\\(_dot\\)\\>"
(0 (progn (compose-region (match-beginning 1) (match-end 2)
(concatenate 'string (match-string 1) " ̇" )) nil)))))
BUT: I see a visual artifact character just before the composed character. Test this out by writing "x_dot" or something similar in the *scratch* buffer after executing the above.
This artifact comes and goes like a phantom. This behavior doesn't occur when composing normal characters like "o" and "-", as in the following example.
(font-lock-add-keywords
nil
`(("\\<\\(\\w\\)\\(_dash\\)\\>"
(0 (progn (compose-region (match-beginning 1) (match-end 2)
(concatenate 'string (match-string 1) "-" )) nil)))))
And then typing in "x_dash" somewhere.
What is going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论如何,您的第一个示例在 OS X 上的前沿 Emacs 中运行良好,没有任何瑕疵。您可能会看到特定于您平台的 emacs UI 和/或字体库的渲染怪癖。如果您发布有关您正在运行的 Emacs 的更多信息,比我更专业的人可能能够确认该问题。
For what it's worth, your first example works fine without artifacts in my bleeding-edge Emacs on OS X. You're probably seeing a rendering quirk specific to your platform's emacs UI and/or font library. If you post more information about the Emacs you're running, people more expert than me might be able to confirm the issue.