Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun patch (func pattern patch)
- "Patch a function definition by replacing `pattern' by `patch'."
- (and (byte-code-function-p (symbol-function func))
- (error "Symbol `%s' is bound to a byte compiled function." func))
- (fset func (repl (symbol-function func) pattern patch)))
- (defun repl (exp pattern patch)
- (cond
- ((null exp) nil)
- ((listp exp)
- (let ((expr (repl (car exp) pattern patch)))
- (cons
- (if (equal expr pattern) patch expr)
- (repl (cdr exp) pattern patch))))
- (t exp)))
Advertisement
Add Comment
Please, Sign In to add comment