let
Binds VariablesEmacs Lisp supports two different ways of binding variable names to their values. These ways affect the parts of your program where a particular binding is valid. For historical reasons, Emacs Lisp uses a form of variable binding called dynamic binding by default. However, in this manual we discuss the preferred form of binding, called lexical binding, unless otherwise noted (in the future, the Emacs maintainers plan to change the default to lexical binding). If you have programmed in other languages before, you’re likely already familiar with how lexical binding behaves.
In order to use lexical binding in a program, you should add this to the first line of your Emacs Lisp file:
;;; -*- lexical-binding: t -*-
For more information about this, see Variable Scoping in The Emacs Lisp Reference Manual.