Emacs: Display Lambda as λ

By Xah Lee. Date: . Last updated: .

Emacs 24.4 has a nice prettify-symbols-mode. In lisp modes, it displays lambda as “λ”. [see Emacs 24.4 Features (released 2014-10)]

emacs pretty lambda 26110
emacs prettify-symbols-mode

Alt+x prettify-symbols-mode to activate it.

Open a emacs lisp file. (For example, Alt+x describe-functionCtrl+h f】 then type byte-compile, then click to open the lisp source code file.) Then, search for “lambda”. Then, Alt+x prettify-symbols-mode to watch it change.

Note that it only DISPLAYS the function named “lambda” as λ, it doesn't really change the text.


To set it globally, put the following in your emacs init:

;; display “lambda” as “λ”
(global-prettify-symbols-mode 1)
emacs pretty lambda 44670
emacs prettify-symbols-mode

Adding Support for Pretty Lambda Mode

prettify-symbols-mode only works for major modes that supports it.

To add support, in your major mode, do:

(setq prettify-symbols-alist '(("lambda" . 955)))

The 955 is Unicode codepoint for λ in decimal. To find the Unicode codepoint of a char, type the char, then Alt+x describe-char. [see Emacs: Unicode Tutorial]

You can add other pairs. For example, to have arrow, do:

(setq prettify-symbols-alist
        ("lambda" . 955) ; λ
        ("->" . 8594)    ;         ("=>" . 8658)    ;         ("map" . 8614)    ;         ))

You can add it as a hook for any major mode. Here's a example:

(defun my-add-pretty-lambda ()
  "make some word or string show as pretty Unicode symbols"
  (setq prettify-symbols-alist
          ("lambda" . 955) ; λ
          ("->" . 8594)    ;           ("=>" . 8658)    ;           ("map" . 8614)   ;           )))

(add-hook 'clojure-mode-hook 'my-add-pretty-lambda)
(add-hook 'haskell-mode-hook 'my-add-pretty-lambda)
(add-hook 'shen-mode-hook 'my-add-pretty-lambda)
(add-hook 'tex-mode-hook 'my-add-pretty-lambda)

[see Emacs: What is Hook]

For other math symbols you might want to add, see:

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode

Emacs Init

Init Basics


text editing