Questions tagged [local-functions]

7 questions
14
votes
1 answer

Emacs let-bound advice

I'd like to temporarily override a function in a piece of code. Take, for example, the following: (defun nadvice/load-quiet (args) (cl-destructuring-bind (file &optional noerror nomessage nosuffix must-suffix) args (list file…
PythonNut
  • 10,243
  • 2
  • 29
  • 75
9
votes
1 answer

Override a function locally, but allow calls to the original function

The advice feature allows modifying the behavior of a function globally. An advice definition can make calls to the original function. (defadvice foo (around foo-bar activate compile) "Always set `qux' to t when running `foo'." (let ((qux t)) …
8
votes
3 answers

Are local nested functions possible in elisp?

It it possible to declare functions whose names are only available in the scope of another function, similar to let? e.g.: (defun my-fn (x y) (let ((my-local-fn (lambda (a b) (message "%S" (- a b))))) (my-local-fn x y) (my-local-fn y x))
ideasman42
  • 8,375
  • 1
  • 28
  • 105
1
vote
1 answer

Is there some way to have a local defalias?

I have some very long function names I want to use short forms for in particular files, eg (defalias-local avlfn a-very-long-function-name) Is that possible, or is that something I may have to write myself? Can I define something like what within a…
vfclists
  • 1,347
  • 1
  • 11
  • 28
0
votes
3 answers

How did `cl-flet` got circumvented?

I want to slightly alter the behavior of counsel-fzf by locally changing the definition of counsel-fzf-action, which activates in the end of the definition of the former. See the source code of counsel-fzf (please pay attention to the second last…
0
votes
1 answer

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

I want to override the function helm-swoop-pre-input-optimize in man mode using its hook, but not anywhere else. Is there something similar to make-local-variable for functions?
HappyFace
  • 751
  • 4
  • 16
0
votes
1 answer

Recursion with let and cl-labels or just cl-letf?

I found this code on stackoverflow (from Rainer Joswig): (defun listFormat () (cl-labels ((place-index (idx l) (if (null l) nil (append (list (first l)) (list idx) (place-index (+ idx 1) (rest…
147pm
  • 2,907
  • 1
  • 18
  • 39