I want to thank phils and sds for providing their answers. After
learning from them and a bit more research, I have come to an
understanding mostly from an excellently written article, Make
flet great again (by Chris
The article explained that cl-flet is lexically scoped (as in
flet in common lisp), and therefore in my use case
There are many options for overriding functions, with many different behaviours. https://stackoverflow.com/questions/39550578/in-emacs-what-is-the-difference-between-cl-flet-and-cl-letf will probably resolve the confusion for you.
The first thing to know is that cl-flet is not the same thing as flet!
flet was dynamically scoped (and hence would have worked ...
You are out of luck here; this is the correct intended behavior.
#'counsel-fzf-action refers to the global function definition of counsel-fzf-action, not the local one.
The cl-flet binding is local, similar to the lexical binding of let:
unless the variable being bound is dynamic (i.e., defined using defvar), the nested functions do not see the binding.