I'm using prettify-symbol mode together with Pragmata Pro.el. Ligatures work perfectly fine in the source code but for some reason with comments they don't. I think I'm missing something since it's not the first time I've fought with ligatures in Emacs.
When symbols are composed with
prettify-symbols-mode is controlled by
prettify-symbols-compose-predicate. By default this will only compose symbols if they are at a word boundary and not inside a comment or string. It checks the parser state with
syntax-ppss to verify that the point is outside of a comment or string. We can change this to only check if we outside a string. That way it will compose symbols in comments as well.
The only part of this function we changed was to change
(nth 8 (syntax-ppss)) (which means in comment or string) to
(nth 3 (syntax-ppss)) (which means in string).
(setq prettify-symbols-compose-predicate (defun my-prettify-symbols-default-compose-p (start end _match) "Same as `prettify-symbols-default-compose-p', except compose symbols in comments as well." (let* ((syntaxes-beg (if (memq (char-syntax (char-after start)) '(?w ?_)) '(?w ?_) '(?. ?\\))) (syntaxes-end (if (memq (char-syntax (char-before end)) '(?w ?_)) '(?w ?_) '(?. ?\\)))) (not (or (memq (char-syntax (or (char-before start) ?\s)) syntaxes-beg) (memq (char-syntax (or (char-after end) ?\s)) syntaxes-end) (nth 3 (syntax-ppss)))))))