How to make emacs display math character combining in font lock mode?

I am trying to get emacs to correctly display mathematical combinations of characters, such as diasesis, over a bar, etc. in font lock mode. The goal is to write something mathematical, such as x_dot, and display it as "ẋ", or x_bar as "x̄".

This is what I still have, and it basically 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 of the character in front of the composed character. Check this by writing "x_dot" or something similar in the * scratch * buffer after doing the above.

This artifact comes and goes like a phantom. This behavior does not occur when composing normal characters, such as "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)))))

"x_dash" -.

?

+3
1

, , Emacs OS X. , emacs / . Emacs, , , , , .

+2

All Articles