Skip to main content
3 of 4
Added the keyboard macro info
phils
  • 53.1k
  • 3
  • 84
  • 127

Keys can only be bound to commands.

A command is (usually) a function which contains an interactive form. This form must be included even if your function takes no arguments.

Hence:

(global-set-key (kbd "C-x 8 l") (lambda () (interactive) (insert "λ")))

In addition, keyboard macros are also commands, and can therefore similarly be bound to keys.

"λ" is a valid keyboard macro for inserting a lambda character, and so (as per Dan's comment above) the following also works:

(global-set-key (kbd "C-x 8 l") "λ")

See also:

phils
  • 53.1k
  • 3
  • 84
  • 127