Skip to main content
11 votes
Accepted

Are local nested functions possible in elisp?

You can also do it without resorting to cl-lib as follows: (defun my-fn (x y) (let ((my-local-fn (lambda (a b) (message "%S" (- a b))))) (funcall my-local-fn x y) (funcall my-local-fn y x))...
Stefan's user avatar
  • 26.5k
8 votes

Are local nested functions possible in elisp?

You can use cl-flet or cl-labels from cl-lib. The docstrings: (cl-flet ((FUNC ARGLIST BODY...) ...) FORM...) Probably introduced at or before Emacs version 24.3. Make local function definitions. ...
Dan's user avatar
  • 33.1k
2 votes

How did `cl-flet` got circumvented?

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, ...
sds's user avatar
  • 6,124
1 vote
Accepted

Is there some way to have a local defalias?

No, there really isn’t a built–in way to scope names to a particular file or package. Loading a file just adds new things to the global environment, or changes things in the global environment. The ...
db48x's user avatar
  • 18.4k
1 vote

How did `cl-flet` got circumvented?

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 ...
phils's user avatar
  • 51.7k
1 vote
Accepted

Is it possible to make a function local to the buffer?

At first the general statement: There is no buffer-local setting for the function cell of a symbol. Now, I am just putting together the comments of lawlist and John Kitchin. One can call an ...
Tobias's user avatar
  • 33.3k

Only top scored, non community-wiki answers of a minimum length are eligible