aboutsummaryrefslogtreecommitdiffstats
path: root/oni-gui.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2021-03-16 23:31:03 -0700
committerGravatar Tom Willemse2021-03-16 23:31:03 -0700
commit59badf01c2636a9a56b1240d227fa127092bc79d (patch)
tree9594c3d98fac143ca8dc1272140d39e6b99e5f18 /oni-gui.el
parenta3cc0b0b36d9441664a7698ba70579db64da7532 (diff)
downloademacs-config-59badf01c2636a9a56b1240d227fa127092bc79d.tar.gz
emacs-config-59badf01c2636a9a56b1240d227fa127092bc79d.zip
Add ligatures supported by Fantasque Sans Mono
Diffstat (limited to 'oni-gui.el')
-rw-r--r--oni-gui.el25
1 files changed, 23 insertions, 2 deletions
diff --git a/oni-gui.el b/oni-gui.el
index 85c9519..352fe8d 100644
--- a/oni-gui.el
+++ b/oni-gui.el
@@ -65,6 +65,24 @@ If FRAME is nil, they’re set for the current frame."
(set-fontset-font t ?✿ dejavu-sans-mono frame)
(set-fontset-font t ?✓ dejavu-sans-mono frame)))
+;; Thanks to the article at
+;; https://andreyorst.gitlab.io/posts/2020-07-21-programming-ligatures-in-emacs/
+(defun oni-gui-setup-ligatures (&optional _)
+ "Define ligatures supported by Fantasque Sans Mono."
+ (let ((ligatures
+ `((?= . ,(regexp-opt '("==" "===" "=/=" "=>" "==>" "=>>" "=<<")))
+ (?! . ,(regexp-opt '("!=" "!==")))
+ (?< . ,(regexp-opt '("<-<" "<<-" "<--" "<-" "<->" "<=<" "<<=" "<=="
+ "<=>" "<~>" "<~~" "<~" "<<<" "<<" "<=" "<>"
+ "<|||" "<||" "<|" "<|>" "<!--")))
+ (?- . ,(regexp-opt '("->" "-->" "->>" "-<" "-<<")))
+ (?> . ,(regexp-opt '(">->" ">=>" ">>=" ">>-" ">-" ">=" ">>" ">>>")))
+ (?~ . ,(regexp-opt '("~~" "~>" "~~>")))
+ (?| . ,(regexp-opt '("|>" "||>" "|||>"))))))
+ (dolist (char-regexp ligatures)
+ (set-char-table-range composition-function-table (car char-regexp)
+ `([,(cdr char-regexp) 0 font-shape-gstring])))))
+
(with-eval-after-load 'isearch
(diminish 'isearch-mode (string ?\s oni-gui-isearch-icon)))
(with-eval-after-load 'autorevert
@@ -90,8 +108,11 @@ _bi_: Auto Insert ^^ ^^
(mode-icons-mode)
(if (daemonp)
- (add-hook 'after-make-frame-functions #'oni-gui-setup-fontsets)
- (oni-gui-setup-fontsets nil))
+ (progn
+ (add-hook 'after-make-frame-functions #'oni-gui-setup-fontsets)
+ (add-hook 'after-make-frame-functions #'oni-gui-setup-ligatures))
+ (oni-gui-setup-fontsets nil)
+ (oni-gui-setup-ligatures))
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-c c") 'oni-gui-hydra/body)