about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--emacs/.emacs.d/wpc/fonts.el31
-rw-r--r--emacs/.emacs.d/wpc/wpc-ui.el1
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)