This page is about displaying the word ‘lambda’ using the Greek letter. See also PrettySymbol.

Using prettify-symbols-mode

Emacs 24.4 introduced a minor mode called ‘prettify-symbols-mode’.

(defun my-pretty-lambda ()
  "make some word or string show as pretty Unicode symbols"
  (setq prettify-symbols-alist
          ("lambda" . 955) ; λ

(add-hook 'scheme-mode-hook 'my-pretty-lambda)
(global-prettify-symbols-mode 1)

The snippet above works only when ‘scheme-mode’ is on. Add more hooks if you wish to get other major modes working.

See also:

Using Character Composition

Library pretty-lambdada.el defines commands, including minor modes (local and global), that let you do this, either for specific modes or generally. The core display code is similar to the following snippet:

(defun pretty-lambdas ()
   nil `(("(\\(lambda\\>\\)"
          (0 (progn (compose-region (match-beginning 1) (match-end 1)
                                    ,(make-char 'greek-iso8859-7 107))

There are several versions of such snippets floating around. The one above is from LawrenceMitchell, modified from StefanMonnier’s rewrite of OliverScholz’s rewrite of LukeGorrie’s original pretty-lambda.el code (

And here is a variant by TrentBuck:

(font-lock-add-keywords 'emacs-lisp-mode
  '(("(\\(lambda\\)\\>" (0 (prog1 ()
                             (compose-region (match-beginning 1)
                                             (match-end 1)

I stopped using pretty-lambda.el because Emacs was actually saving weird escape characters in my files such that when I reloaded them I’d still get lambda-symbols, even with this turned off. But it makes the files unreadable to other programs. Does anyone else have this problem, and know the fix? Since it’s all done in font-lock I didn’t expect the saved files to be affected. – LukeGorrie

This should happen only if the file was saved in the coding system Emacs Mule, because emacs-mule preserves the composition property. (Composition is actually part of Emacs’ m17n support.) Normally you should not use emacs-mule; however, auto-save files are saved in that coding system. So if you restore a file after a crash, for instance, you can get something like what you describe. A fix would be to use a hook to remove all composition properties before auto-saving. – OliverScholz

Using Font-Lock and Overlays

This library defines a minor mode that uses font-lock and overlays to display ‘lambda’ as the Greek letter:

I use the misc-fixed font instead of the default, so lambda-mode displayed what looked like a Korean character. You can fix it by adding to your .emacs:

(setq lambda-symbol (string #x1d77a))

Using an Image

Sugawara offers another approach: a minor mode that displays ‘lambda’ as a large Greek letter using an image.

(defvar big-lambda-image
 'jpeg t))

(defvar big-lambda-font-lock-keywords
  '((".+" (0 (prog1 nil
                (match-beginning 0) (match-end 0)))))
     (0 (prog1 nil
          (big-lambda-region (match-beginning 1) (match-end 1)))))))
(defun big-lambda-remove-region (beg end)
  "Remove big lambda property in region between BEG and END."
  (let (pos)
    (while (setq pos (text-property-any beg end 'display big-lambda-image))
       (or (next-single-property-change pos 'display) end)

(defun big-lambda-region (beg end)
  "Add big lambda property in region between BEG and END."
  (put-text-property beg end 'display big-lambda-image))

(define-minor-mode big-lambda-mode
  "Display big lambda."
  :lighter " Lambda"
  (if big-lambda-mode
          (let ((font-lock-keywords big-lambda-font-lock-keywords))
        (font-lock-add-keywords nil big-lambda-font-lock-keywords))
    (font-lock-remove-keywords nil big-lambda-font-lock-keywords)
      (let ((modified-p (buffer-modified-p)))
        (big-lambda-remove-region (point-min) (point-max))
        (set-buffer-modified-p modified-p)))))

(defun big-lambda-mode-turn-on ()
  "Turn on `big-lambda-mode'."
  (big-lambda-mode 1))

(add-hook 'emacs-lisp-mode 'big-lambda-mode-turn-on)