emacs-config/unused/10-ligatures.org

1.5 KiB

Ligatures

Ligatures in programming fonts can help reading code. this Config uses the composition table technique.

  (when (window-system)
    (set-frame-font "Fira Code"))
  (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]))))

  (add-hook 'eshell-mode-hook (lambda () (setq auto-composition-mode nil)))