diff --git a/Emacs-instructions.md b/Emacs-instructions.md index 049a808..3b07dd3 100644 --- a/Emacs-instructions.md +++ b/Emacs-instructions.md @@ -1,4 +1,101 @@ -Put this lisp in your `.emacs` (thanks [Sean Farley](https://github.com/seanfarley) for putting this together; extended by [Jason Blevins](https://github.com/jrblevin)): +There are a few options when it comes down to using ligatures in +Emacs. They are listed in order of preferred to less-preferred. Pick one! + +- [Using composition mode in Emacs Mac port](#using-composition-mode-in-emacs-mac-port) +- [Using prettify-symbols](#using-prettify-symbols) +- [Using composition char table](#using-composition-char-table) +- [Using font-lock keywords](#using-font-lock-keywords) + +### Using composition mode in Emacs Mac port + +If you're using the latest [Mac port](https://bitbucket.org/mituharu/emacs-mac) +of Emacs (by Mitsuharu Yamamoto) for macOS, you can use: + +```elisp +(mac-auto-operator-composition-mode) +``` + +This is generally the easiest solution, but can only be used on macOS. + +### Using prettify-symbols + +These instructions are pieced together by [@Triavanicus](https://github.com/Triavanicus), +taking some pieces from: [Hasklig-Mode](https://github.com/minad/hasklig-mode). + +This method requires you to install the Fira Code Symbol font, made by [@siegebell](https://github.com/siegebell): +https://github.com/tonsky/FiraCode/issues/211#issuecomment-239058632 + +```elisp +(defun fira-code-mode--make-alist (list) + "Generate prettify-symbols alist from LIST." + (let ((idx -1)) + (mapcar + (lambda (s) + (setq idx (1+ idx)) + (let* ((code (+ #Xe100 idx)) + (width (string-width s)) + (prefix ()) + (suffix '(?\s (Br . Br))) + (n 1)) + (while (< n width) + (setq prefix (append prefix '(?\s (Br . Bl)))) + (setq n (1+ n))) + (cons s (append prefix suffix (list (decode-char 'ucs code)))))) + list))) + +(defconst fira-code-mode--ligatures + '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" + "{-" "[]" "::" ":::" ":=" "!!" "!=" "!==" "-}" + "--" "---" "-->" "->" "->>" "-<" "-<<" "-~" + "#{" "#[" "##" "###" "####" "#(" "#?" "#_" "#_(" + ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" + "/**" "/=" "/==" "/>" "//" "///" "&&" "||" "||=" + "|=" "|>" "^=" "$>" "++" "+++" "+>" "=:=" "==" + "===" "==>" "=>" "=>>" "<=" "=<<" "=/=" ">-" ">=" + ">=>" ">>" ">>-" ">>=" ">>>" "<*" "<*>" "<|" "<|>" + "<$" "<$>" "" "->" "->>" "-<" "-<<" "-~" - "#{" "#[" "##" "###" "####" "#(" "#?" "#_" "#_(" - ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" - "/**" "/=" "/==" "/>" "//" "///" "&&" "||" "||=" - "|=" "|>" "^=" "$>" "++" "+++" "+>" "=:=" "==" - "===" "==>" "=>" "=>>" "<=" "=<<" "=/=" ">-" ">=" - ">=>" ">>" ">>-" ">>=" ">>>" "<*" "<*>" "<|" "<|>" - "<$" "<$>" "