使用建议更改 elisp 函数体中的表达式
Change expression in body of elisp function with advice
添加通知时如何匹配 elisp 函数正文中的特定表达式?具体来说,在下面的例子中,我想建议函数使用 find-file-noselect
代替 find-file
,即。
(find-file path)
行将生效 (find-file-noselect path)
.
(defun tst-fun (path line column)
(find-file path)
(goto-char (point-min))
(forward-line (1- line))
(forward-char column))
;; not sure how to structure this
(defadvice tst-fun (around noselect activate)
(find-file-noselect (ad-get-arg 0))
ad-do-it)
我宁愿将其设置为 ad-add-function
,但我正在尝试先让它正常工作。
您可以在建议中暂时将 find-file
重新定义为 find-file-noselect
。
(require 'cl)
(defadvice tst-fun (around noselect activate)
(flet ((find-file (&rest args)
(apply 'find-file-noselect args)))
ad-do-it))
添加通知时如何匹配 elisp 函数正文中的特定表达式?具体来说,在下面的例子中,我想建议函数使用 find-file-noselect
代替 find-file
,即。
(find-file path)
行将生效 (find-file-noselect path)
.
(defun tst-fun (path line column)
(find-file path)
(goto-char (point-min))
(forward-line (1- line))
(forward-char column))
;; not sure how to structure this
(defadvice tst-fun (around noselect activate)
(find-file-noselect (ad-get-arg 0))
ad-do-it)
我宁愿将其设置为 ad-add-function
,但我正在尝试先让它正常工作。
您可以在建议中暂时将 find-file
重新定义为 find-file-noselect
。
(require 'cl)
(defadvice tst-fun (around noselect activate)
(flet ((find-file (&rest args)
(apply 'find-file-noselect args)))
ad-do-it))