diff options
author | William Carroll <wpcarro@gmail.com> | 2020-09-04T20·03+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-09-04T20·03+0100 |
commit | aae5b4c88c443e6105ba19dd9bc0fab58e8ae1b9 (patch) | |
tree | ed7e987cdf279511b1af91db253c2de9abb277a4 /emacs/.emacs.d/wpc | |
parent | 97c2706821c8279ea14afaffa2546e0b38e45ca3 (diff) |
Enable font ligatures for Emacs 27!
Now that Emacs is capable a rendering font ligatures, I defined a function to enable them in fonts.el. Everything works, and it's beautiful.
Diffstat (limited to 'emacs/.emacs.d/wpc')
-rw-r--r-- | emacs/.emacs.d/wpc/fonts.el | 31 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/wpc-ui.el | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/emacs/.emacs.d/wpc/fonts.el b/emacs/.emacs.d/wpc/fonts.el index 55fd0eae2f65..1c8f2dee0741 100644 --- a/emacs/.emacs.d/wpc/fonts.el +++ b/emacs/.emacs.d/wpc/fonts.el @@ -137,5 +137,36 @@ The size of the font is determined by `fonts-size'." (interactive) (fonts-whitelist-set (fonts-current))) +(defun fonts-enable-ligatures () + "Call this function to enable ligatures." + (interactive) + (let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)") + (35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)") ;; + (36 . ".\\(?:>\\)") + (37 . ".\\(?:\\(?:%%\\)\\|%\\)") + (38 . ".\\(?:\\(?:&&\\)\\|&\\)") + (42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)") ;; + (43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)") + (45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)") + (46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=-]\\)") ;; + (47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)") + (48 . ".\\(?:x[a-zA-Z]\\)") + (58 . ".\\(?:::\\|[:=]\\)") + (59 . ".\\(?:;;\\|;\\)") + (60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)") + (61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)") + (62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)") + (63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)") + (91 . ".\\(?:]\\)") + (92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)") + (94 . ".\\(?:=\\)") + (119 . ".\\(?:ww\\)") + (123 . ".\\(?:-\\)") + (124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)") + (126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)")))) + (dolist (char-regexp alist) + (set-char-table-range composition-function-table (car char-regexp) + `([,(cdr char-regexp) 0 font-shape-gstring]))))) + (provide 'fonts) ;;; fonts.el ends here diff --git a/emacs/.emacs.d/wpc/wpc-ui.el b/emacs/.emacs.d/wpc/wpc-ui.el index cce217f03a18..35ca918763eb 100644 --- a/emacs/.emacs.d/wpc/wpc-ui.el +++ b/emacs/.emacs.d/wpc/wpc-ui.el @@ -164,6 +164,7 @@ (laptop-battery-display)) (fonts-whitelist-set "JetBrainsMono") +(fonts-enable-ligatures) (colorscheme-whitelist-set 'doom-solarized-light) (modeline-setup) |