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 behav开发者_JAVA百科ior 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?
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.
精彩评论