用建议改变elisp函数体中的表达式

时间:2016-10-27 22:16:47

标签: emacs elisp defadvice

在添加建议时,如何匹配elisp函数中正文中的特定表达式?具体来说,在以下示例中,我建议使用$("#parent").html(Basic); //If you are using JQuery 代替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) ,但我想先让它先工作。

1 个答案:

答案 0 :(得分:2)

您可以在建议中暂时将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))