Fork me on GitHub
#emacs
<
2022-05-30
>
Benjamin15:05:48

jo how do I override a function locally? Like in clojure with binding I can advice it and check the presence of some local variable

Benjamin15:05:37

for my acute use case I figured out how to not need such a workaround

vemv16:05:02

let / let* can just do that (like clojure binding) since emacs traditionally has always had dynamic scope For the last 10 years the direction has changed, so it's worth checking out the rules for which scope applies when

Benjamin17:05:23

yea for variables but for functions? Ah does cl-flet work? (nvm-flet makes a special symbol of the input)

vemv18:05:18

ah no idea, I only vaguely recall about this stuff

vemv18:05:40

normally I override the defun altogether (however I admit it's a bit :face_with_cowboy_hat:ish)

vemv18:05:52

perhaps you can advice it with around and perform your logic conditionally e.g. (setq-local foo 'yeah) and then (if foo ,,,) in your advice

Benjamin18:05:08

I think that would be the way

Benjamin18:05:30

one day we'll have an emacs written in clojure

clojure-spin 1
ag23:05:33

> how do I override a function locally? it depends on what you're trying to do. I often have to refer to this SO post, because I can't memorize these three things https://stackoverflow.com/questions/39550578/in-emacs-what-is-the-difference-between-cl-flet-and-cl-letf

Benjamin08:05:08

ah cl-letf actually does override the symbol function place, nice