firacode.el (8993B)
1 2 ;; Taken from https://gist.github.com/mordocai/50783defab3c3d1650e068b4d1c91495 3 ;; Modified to point to icons-in-terminal codepoints 4 5 (defconst firacode-codepoint-start #xedff) 6 7 ;;; Fira code 8 ;; This works when using emacs --daemon + emacsclient 9 (add-hook 'after-make-frame-functions (lambda (frame) (set-fontset-font t '(#Xedff . #Xee6d) "icons-in-terminal"))) 10 ;; This works when using emacs without server/client 11 (set-fontset-font t '(#Xedff . #Xee6e) "icons-in-terminal") 12 ;; I haven't found one statement that makes both of the above situations work, so I use both for now 13 14 (defconst fira-code-font-lock-keywords-alist 15 (mapcar (lambda (regex-char-pair) 16 `(,(car regex-char-pair) 17 (0 (prog1 () 18 (compose-region (match-beginning 1) 19 (match-end 1) 20 ;; The first argument to concat is a string containing a literal tab 21 ,(concat " " (list (decode-char 'ucs (cadr regex-char-pair))))))))) 22 `(("\\(www\\)" ,(+ firacode-codepoint-start 0)) 23 ("[^/]\\(\\*\\*\\)[^/]" ,(+ firacode-codepoint-start 1)) 24 ("\\(\\*\\*\\*\\)" ,(+ firacode-codepoint-start 2)) 25 ("\\(\\*\\*/\\)" ,(+ firacode-codepoint-start 3)) 26 ("\\(\\*>\\)" ,(+ firacode-codepoint-start 4)) 27 ("[^*]\\(\\*/\\)" ,(+ firacode-codepoint-start 5)) 28 ("\\(\\\\\\\\\\)" ,(+ firacode-codepoint-start 6)) 29 ("\\(\\\\\\\\\\\\\\)" ,(+ firacode-codepoint-start 7)) 30 ("\\({-\\)" ,(+ firacode-codepoint-start 8)) 31 ("\\(\\[\\]\\)" ,(+ firacode-codepoint-start 9)) 32 ("\\(::\\)" ,(+ firacode-codepoint-start 10)) 33 ("\\(:::\\)" ,(+ firacode-codepoint-start 11)) 34 ("[^=]\\(:=\\)" ,(+ firacode-codepoint-start 12)) 35 ("\\(!!\\)" ,(+ firacode-codepoint-start 13)) 36 ("\\(!=\\)" ,(+ firacode-codepoint-start 14)) 37 ("\\(!==\\)" ,(+ firacode-codepoint-start 15)) 38 ("\\(-}\\)" ,(+ firacode-codepoint-start 16)) 39 ("\\(--\\)" ,(+ firacode-codepoint-start 17)) 40 ("\\(---\\)" ,(+ firacode-codepoint-start 18)) 41 ("\\(-->\\)" ,(+ firacode-codepoint-start 19)) 42 ("[^-]\\(->\\)" ,(+ firacode-codepoint-start 20)) 43 ("\\(->>\\)" ,(+ firacode-codepoint-start 21)) 44 ("\\(-<\\)" ,(+ firacode-codepoint-start 22)) 45 ("\\(-<<\\)" ,(+ firacode-codepoint-start 23)) 46 ("\\(-~\\)" ,(+ firacode-codepoint-start 24)) 47 ("\\(#{\\)" ,(+ firacode-codepoint-start 25)) 48 ("\\(#\\[\\)" ,(+ firacode-codepoint-start 26)) 49 ("\\(##\\)" ,(+ firacode-codepoint-start 27)) 50 ("\\(###\\)" ,(+ firacode-codepoint-start 28)) 51 ("\\(####\\)" ,(+ firacode-codepoint-start 29)) 52 ("\\(#(\\)" ,(+ firacode-codepoint-start 30)) 53 ("\\(#\\?\\)" ,(+ firacode-codepoint-start 31)) 54 ("\\(#_\\)" ,(+ firacode-codepoint-start 32)) 55 ("\\(#_(\\)" ,(+ firacode-codepoint-start 33)) 56 ("\\(\\.-\\)" ,(+ firacode-codepoint-start 34)) 57 ("\\(\\.=\\)" ,(+ firacode-codepoint-start 35)) 58 ("\\(\\.\\.\\)" ,(+ firacode-codepoint-start 36)) 59 ("\\(\\.\\.<\\)" ,(+ firacode-codepoint-start 37)) 60 ("\\(\\.\\.\\.\\)" ,(+ firacode-codepoint-start 38)) 61 ("\\(\\?=\\)" ,(+ firacode-codepoint-start 39)) 62 ("\\(\\?\\?\\)" ,(+ firacode-codepoint-start 40)) 63 ("\\(;;\\)" ,(+ firacode-codepoint-start 41)) 64 ("\\(/\\*\\)" ,(+ firacode-codepoint-start 42)) 65 ("\\(/\\*\\*\\)" ,(+ firacode-codepoint-start 43)) 66 ("\\(/=\\)" ,(+ firacode-codepoint-start 44)) 67 ("\\(/==\\)" ,(+ firacode-codepoint-start 45)) 68 ("\\(/>\\)" ,(+ firacode-codepoint-start 46)) 69 ("\\(//\\)" ,(+ firacode-codepoint-start 47)) 70 ("\\(///\\)" ,(+ firacode-codepoint-start 48)) 71 ("\\(&&\\)" ,(+ firacode-codepoint-start 49)) 72 ("\\(||\\)" ,(+ firacode-codepoint-start 50)) 73 ("\\(||=\\)" ,(+ firacode-codepoint-start 51)) 74 ("[^|]\\(|=\\)" ,(+ firacode-codepoint-start 52)) 75 ("\\(|>\\)" ,(+ firacode-codepoint-start 53)) 76 ("\\(\\^=\\)" ,(+ firacode-codepoint-start 54)) 77 ("\\(\\$>\\)" ,(+ firacode-codepoint-start 55)) 78 ("\\(\\+\\+\\)" ,(+ firacode-codepoint-start 56)) 79 ("\\(\\+\\+\\+\\)" ,(+ firacode-codepoint-start 57)) 80 ("\\(\\+>\\)" ,(+ firacode-codepoint-start 58)) 81 ("\\(=:=\\)" ,(+ firacode-codepoint-start 59)) 82 ("[^!/]\\(==\\)[^>]" ,(+ firacode-codepoint-start 60)) 83 ("\\(===\\)" ,(+ firacode-codepoint-start 61)) 84 ("\\(==>\\)" ,(+ firacode-codepoint-start 62)) 85 ("[^=]\\(=>\\)" ,(+ firacode-codepoint-start 63)) 86 ("\\(=>>\\)" ,(+ firacode-codepoint-start 64)) 87 ("\\(<=\\)" ,(+ firacode-codepoint-start 65)) 88 ("\\(=<<\\)" ,(+ firacode-codepoint-start 66)) 89 ("\\(=/=\\)" ,(+ firacode-codepoint-start 67)) 90 ("\\(>-\\)" ,(+ firacode-codepoint-start 68)) 91 ("\\(>=\\)" ,(+ firacode-codepoint-start 69)) 92 ("\\(>=>\\)" ,(+ firacode-codepoint-start 70)) 93 ("[^-=]\\(>>\\)" ,(+ firacode-codepoint-start 71)) 94 ("\\(>>-\\)" ,(+ firacode-codepoint-start 72)) 95 ("\\(>>=\\)" ,(+ firacode-codepoint-start 73)) 96 ("\\(>>>\\)" ,(+ firacode-codepoint-start 74)) 97 ("\\(<\\*\\)" ,(+ firacode-codepoint-start 75)) 98 ("\\(<\\*>\\)" ,(+ firacode-codepoint-start 76)) 99 ("\\(<|\\)" ,(+ firacode-codepoint-start 77)) 100 ("\\(<|>\\)" ,(+ firacode-codepoint-start 78)) 101 ("\\(<\\$\\)" ,(+ firacode-codepoint-start 79)) 102 ("\\(<\\$>\\)" ,(+ firacode-codepoint-start 80)) 103 ("\\(<!--\\)" ,(+ firacode-codepoint-start 81)) 104 ("\\(<-\\)" ,(+ firacode-codepoint-start 82)) 105 ("\\(<--\\)" ,(+ firacode-codepoint-start 83)) 106 ("\\(<->\\)" ,(+ firacode-codepoint-start 84)) 107 ("\\(<\\+\\)" ,(+ firacode-codepoint-start 85)) 108 ("\\(<\\+>\\)" ,(+ firacode-codepoint-start 86)) 109 ("\\(<=\\)" ,(+ firacode-codepoint-start 87)) 110 ("\\(<==\\)" ,(+ firacode-codepoint-start 88)) 111 ("\\(<=>\\)" ,(+ firacode-codepoint-start 89)) 112 ("\\(<=<\\)" ,(+ firacode-codepoint-start 90)) 113 ("\\(<>\\)" ,(+ firacode-codepoint-start 91)) 114 ("[^-=]\\(<<\\)" ,(+ firacode-codepoint-start 92)) 115 ("\\(<<-\\)" ,(+ firacode-codepoint-start 93)) 116 ("\\(<<=\\)" ,(+ firacode-codepoint-start 94)) 117 ("\\(<<<\\)" ,(+ firacode-codepoint-start 95)) 118 ("\\(<~\\)" ,(+ firacode-codepoint-start 96)) 119 ("\\(<~~\\)" ,(+ firacode-codepoint-start 97)) 120 ("\\(</\\)" ,(+ firacode-codepoint-start 98)) 121 ("\\(</>\\)" ,(+ firacode-codepoint-start 99)) 122 ("\\(~@\\)" ,(+ firacode-codepoint-start 100)) 123 ("\\(~-\\)" ,(+ firacode-codepoint-start 101)) 124 ("\\(~=\\)" ,(+ firacode-codepoint-start 102)) 125 ("\\(~>\\)" ,(+ firacode-codepoint-start 103)) 126 ("[^<]\\(~~\\)" ,(+ firacode-codepoint-start 104)) 127 ("\\(~~>\\)" ,(+ firacode-codepoint-start 105)) 128 ("\\(%%\\)" ,(+ firacode-codepoint-start 106)) 129 ;;("\\(x\\)" ,(+ firacode-codepoint-start 107)) 130 ("[^:=]\\(:\\)[^:=]" ,(+ firacode-codepoint-start 108)) 131 ("[^\\+<>]\\(\\+\\)[^\\+<>]" ,(+ firacode-codepoint-start 109)) 132 ("[^\\*/<>]\\(\\*\\)[^\\*/<>]" ,(+ firacode-codepoint-start 110))))) 133 134 (defun add-fira-code-symbol-keywords () 135 (font-lock-add-keywords nil fira-code-font-lock-keywords-alist)) 136 137 (add-hook 'prog-mode-hook 138 #'add-fira-code-symbol-keywords)