From 50886f0992cf824f87a501cc8d8d8f62e7d2762a Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 9 Oct 2019 19:27:17 +0200 Subject: [PATCH] Add a letrec example to the manuel * doc/lispref/variables.texi (Local Variables): Add a letrec example. --- doc/lispref/variables.texi | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 02e156396db..89dac4f7a4d 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -273,7 +273,17 @@ before any of the local values are computed. The values are then assigned to the locally bound variables. This is only useful when lexical binding is in effect, and you want to create closures that refer to bindings that would otherwise not yet be in effect when using -@code{let}. +@code{let*}. + +For instance, here's a closure that removes itself from a hook after +being run once: + +@lisp +(letrec ((hookfun (lambda () + (message "Run once") + (remove-hook 'post-command-hook hookfun)))) + (add-hook 'post-command-hook hookfun)) +@end lisp @end defspec Here is a complete list of the other facilities that create local -- 2.39.5