subj。 喜欢的东西:保存原始功能,在本地用flet重新绑定并从新里面调用原始功能?
(lexical-let (oldf #'original-func)
(flet ((original-func (arg)
do-something
(funcall oldf arg)))
do-something))
不工作:(
subj。 喜欢的东西:保存原始功能,在本地用flet重新绑定并从新里面调用原始功能?
(lexical-let (oldf #'original-func)
(flet ((original-func (arg)
do-something
(funcall oldf arg)))
do-something))
不工作:(
希望这将有助于你的语法,呼叫交换功能调用foo1但执行foo2的
你可以这样写一个。有用的宏观与替换功能与新功能的同时执行你传递一个体结合老功能。
(defun foo1()
(insert "hi foo1"))
(defun foo2()
(insert "hi foo2"))
(defun swap-function(old new)
(let ((save-func (symbol-function old)))
(fset old (symbol-function new))
(funcall old)
(fset old save-func)))
(swap-function #'foo1 #'foo2)
目前在电子阅读器没有宏macs-lisp,您需要明确使用 symbol-function
。
(defun test-1 (x)
(message "base test %s" x))
(let ((old-test-1 (symbol-function 'test-1))
(z 10))
(flet ((test-1 (y)
(funcall old-test-1 y)
(message "extended test %s" y)))
(nic-test-1 z)))
如果你想使用它作为一个封闭你需要使用的lexical-let
代替let
或设置lexical-binding
到T
。
谢谢.. .. :) – 2012-02-05 18:28:26
哦,谢谢!不知道符号功能。 – 2012-02-05 18:29:14