1

I am trying to get ligatures working in emacs with "Fantasque Sans Mono Nerd Font Mono" (that's its name...)

My script is the following:

(provide 'add-fantasque-ligatures)

(defconst fantasque-fontlock-keywords-alist
  (mapcar (lambda (regex-char-pair)
            `(,(car regex-char-pair)
              (0 (prog1 ()
                   (compose-region (match-beginning 1)
                                   (match-end 1)
                                   ,(concat (list ?\C-i)
                                            (list (decode-char 'ucs (cadr regex-char-pair)))))))))
          '(("\\(!=\\)"               #xe10a)
            ("\\(==\\)"               #xe103)
            ("\\(->\\)"               #xe112)
            ("\\(<-\\)"               #xe121)
            ("[^<]\\(<=\\)"           #xe11b)
            ("\\(&&\\)"               #xe038)
            ("[^>]\\(>=\\)"           #xe10c))))

(defun add-fantasque-ligatures ()
  (font-lock-add-keywords nil fantasque-fontlock-keywords-alist))

(add-hook 'prog-mode-hook
          #'add-fantasque-ligatures)

It works fine, except for the &&. Emacs displays a play button in a filled circle. I penta-checked it, and U+e038 is its unicode value.

I have an idea, though, what emacs does here. There are some other ligatures I checked too, like ||, and emacs displayed a play button in an unfilled circle. I changed the font, and the && and || still did not work. I think there are some unicode characters, that emacs overwrites to make them font-independent. Is there a way though to overcome this problem, and display the correct ligatures?

Drew
  • 29,895
  • 7
  • 74
  • 104
Andy
  • 11
  • 3

0 Answers0