Last active
July 15, 2021 01:56
-
-
Save plaidfinch/dea7bc51101083acb95c875140e2a96d to your computer and use it in GitHub Desktop.
Mappings for prettify-symbols-mode to enable Pragmata Pro's ligatures in Emacs. I've taken some slight liberties with the original ligature map, to suit my own tastes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; PRETTIFY SYMBOLS (with Pragmata Pro) | |
(defun setup-pragmata-ligatures () | |
(setq prettify-symbols-alist | |
(append prettify-symbols-alist | |
'(("!!" . ?) | |
("!=" . ?) | |
("!==" . ?) | |
("!≡" . ?) | |
("!≡≡" . ?) | |
("!>" . ?) | |
("#(" . ?) | |
("#_" . ?) | |
("#{" . ?) | |
("#?" . ?) | |
("#>" . ?) | |
("%=" . ?) | |
("%>" . ?) | |
("<~" . ?) | |
("&%" . ?) | |
("&&" . ?) | |
("&*" . ?) | |
("&+" . ?) | |
("&-" . ?) | |
("&/" . ?) | |
("&=" . ?) | |
("&&&" . ?) | |
("&>" . ?) | |
("$>" . ?) | |
("~>" . ?) | |
;; ("***" . ?) ; I prefer not to use this one | |
("*=" . ?) | |
("*/" . ?) | |
("*>" . ?) | |
("++" . ?) | |
("+++" . ?) | |
("+=" . ?) | |
("+>" . ?) | |
("--" . ?) | |
("-<" . ?) | |
("-<<" . ?) | |
("-=" . ?) | |
("->>" . ?) | |
("---" . ?) | |
("-->" . ?) | |
(".." . ?) | |
("..." . ?) | |
("..<" . ?) | |
(".>" . ?) | |
(".~" . ?) | |
(".=" . ?) | |
("/*" . ?) | |
("//" . ?) | |
("/>" . ?) | |
("/=" . ?) | |
("/==" . ?) | |
("///" . ?) | |
("/**" . ?) | |
("::" . ?) | |
(":=" . ?) | |
(":≡" . ?) | |
(":>" . ?) | |
(":=>" . ?) | |
("<$>" . ?) | |
("<*" . ?) | |
("<*>" . ?) | |
("<+>" . ?) | |
;; ("<-" . ?) ; I like different arrows (see below) | |
("<<" . ?) | |
("<<<" . ?) | |
("<<=" . ?) | |
("<=" . ?) | |
;; ("<=>" . ?) ; I like different arrows (see below) | |
("<>" . ?) | |
("<|>" . ?) | |
("<<-" . ?) | |
("<|" . ?) | |
("<=<" . ?) | |
("<~~" . ?) | |
("<<~" . ?) | |
("<$" . ?) | |
("<+" . ?) | |
("<!>" . ?) | |
("<@>" . ?) | |
("<#>" . ?) | |
("<%>" . ?) | |
("<^>" . ?) | |
("<&>" . ?) | |
("<?>" . ?) | |
("<.>" . ?) | |
("</>" . ?) | |
("<\>" . ?) | |
("<\">" . ?) | |
("<:>" . ?) | |
("<~>" . ?) | |
("<**>" . ?) | |
("<<^" . ?) | |
("<!" . ?) | |
("<@" . ?) | |
("<#" . ?) | |
("<%" . ?) | |
("<^" . ?) | |
("<&" . ?) | |
("<?" . ?) | |
("<." . ?) | |
("</" . ?) | |
("<\\" . ?) | |
("<\"" . ?) | |
("<:" . ?) | |
("<->" . ?) | |
("<!--" . ?) | |
("<--" . ?) | |
("=<<" . ?) | |
("==" . ?) | |
("===" . ?) | |
;; ("==>" . ?) ; I like different arrows (see below) | |
;; ("=>" . ?) ; I like different arrows (see below) | |
("=~" . ?) | |
("=>>" . ?) | |
("≡≡" . ?) | |
("≡≡≡" . ?) | |
("≡:≡" . ?) | |
(">-" . ?) | |
(">=" . ?) | |
(">>" . ?) | |
(">>-" . ?) | |
(">>=" . ?) | |
(">>>" . ?) | |
(">=>" . ?) | |
(">>^" . ?) | |
("??" . ?) | |
("?~" . ?) | |
("?=" . ?) | |
("?>" . ?) | |
("^=" . ?) | |
("^." . ?) | |
("^?" . ?) | |
("^.." . ?) | |
("^<<" . ?) | |
("^>>" . ?) | |
("^>" . ?) | |
("\\\\" . ?) | |
("\\>" . ?) | |
("@>" . ?) | |
("|=" . ?) | |
("||" . ?) | |
("|>" . ?) | |
("|||" . ?) | |
("|+|" . ?) | |
("~=" . ?) | |
("~~>" . ?) | |
("~>>" . ?) | |
;; Personal preference: I like this set of arrows better than default | |
("<-" . ?🡐) | |
("->" . ?🡒) | |
("=>" . ?⇒) | |
("<=>" . ?⟺) | |
("<==>" . ?⟺) | |
("==>" . ?⟹) | |
("<==" . ?⟸) | |
("|->" . ?⟼) | |
("<-|" . ?⟻) | |
("|=>" . ?⟾) | |
("<=|" . ?⟽) | |
)))) | |
(defun refresh-pretty () | |
(prettify-symbols-mode -1) | |
(prettify-symbols-mode +1)) | |
;; Hooks for modes in which to install the Pragmata ligatures | |
(mapc (lambda (hook) | |
(add-hook hook (lambda () (setup-pragmata-ligatures) (refresh-pretty)))) | |
'(text-mode-hook | |
prog-mode-hook)) | |
(global-prettify-symbols-mode +1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you mind sharing how you find the correct glyph character to use it in this code? I would like to build a similar map for other fonts that support ligature. Thanks!