简体   繁体   English

如何使emacs在字体锁定模式下呈现数学组合字符?

[英]How do I make emacs render mathematical combining characters in font-lock mode?

I am trying to get emacs to properly render mathematical combining characters such the diaeresis, over bar, etc in font-lock mode. 我试图让emacs在字体锁定模式下正确渲染数学组合字符,如分音符,条形码等。 The goal is to be able to write something mathematical like x_dot and have it be displayed as "ẋ", or x_bar as "x̄". 目标是能够编写像x_dot这样的数学内容并将其显示为“ẋ”,或将x_bar显示为“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. 在执行上述操作后,通过在* scratch *缓冲区中写入“x_dot”或类似的东西来测试它。

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. 在编写像“o”和“ - ”这样的普通字符时不会发生这种情况,如下例所示。

 (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. 然后在某处键入“x_dash”。

What is going on? 到底是怎么回事?

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. 对于它的价值,你的第一个例子在OS X上我最前沿的Emacs中没有工件的情况下工作得很好。你可能会看到一个特定于你的平台的emacs UI和/或字体库的渲染怪癖。 If you post more information about the Emacs you're running, people more expert than me might be able to confirm the issue. 如果您发布有关您正在运行的Emacs的更多信息,那么比我更专业的人可能能够确认问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM