* lisp/progmodes/prog-mode.el (prettify-symbols--compose-symbol): Refine.

Fix handling of symbols with different syntax at beginning/end or with
symbol rather than word syntax.