I'd rather not use
cl at the same time. However, I really like using
lexical-let to specify the usage of lexical binding on a more granular level.
Is there any equivalent in
cl-lib or vanilla Emacs Lisp?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
Simply require library
cl at compile time, to get the use of its macros (and not get any runtime load). That is where macro
lexical-let is defined.
So all you need is this, to use
(eval-when-compile (require 'cl)) ;; lexical-let
(I put the stuff I use from the library in a comment like that, just to let me know what I'm using from it.)
lexical-let works in all Emacs versions (at least Emacs 20 and later). And yes, it lets you use dynamic binding by default and use lexical binding in a granular way, when you want it.
cl.el is vanilla Emacs, BTW, not a 3rd-party library. It is simply not preloaded. It has the same status as something like Org mode or Calc or