简体   繁体   中英

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. 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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