Last active
May 27, 2016 21:05
-
-
Save fukamachi/4109258 to your computer and use it in GitHub Desktop.
Pretty lambda/nil for Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This function is quoted from this page. Thanks to Tomohiro Matsuyama. | |
;; http://dev.ariel-networks.com/Members/matsuyama/pretty-lambda-in-emacs/ | |
(defun set-pretty-patterns (patterns) | |
(loop for (glyph . pairs) in patterns do | |
(loop for (regexp . major-modes) in pairs do | |
(loop for major-mode in major-modes do | |
(let ((major-mode (intern (concat (symbol-name major-mode) "-mode"))) | |
(n (if (string-match "\\\\([^?]" regexp) 1 0))) | |
(font-lock-add-keywords major-mode | |
`((,regexp (0 (prog1 () | |
(compose-region (match-beginning ,n) | |
(match-end ,n) | |
,glyph))))))))))) | |
(set-pretty-patterns | |
'((?λ ("\\<lambda\\>" lisp lisp-interaction emacs-lisp scheme)) | |
(?φ ("\\<nil\\>" lisp lisp-interaction emacs-lisp scheme)) | |
(?λ ("\\<function\\>" js2)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment