Skip to content

Instantly share code, notes, and snippets.

@fukamachi
Last active May 27, 2016 21:05
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fukamachi/4109258 to your computer and use it in GitHub Desktop.
Save fukamachi/4109258 to your computer and use it in GitHub Desktop.
Pretty lambda/nil for Emacs
;; 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