C-h f perform-replace
说:
Don't use this in your own program unless you want to query and set the mark
just as `query-replace' does. Instead, write a simple loop like this:
(while (re-search-forward "foo[ \t]+bar" nil t)
(replace-match "foobar"))
现在"<\\,(downcase \1)>"
需要用构建正确字符串的 Elisp 表达式替换,例如(format "<%s>" (downcase (match-string 1)))
.
如果您确实需要查询和东西,那么您可能想尝试:C-M-% f\(o\)o RET bar \,(downcase \1) baz RET
然后C-x RET RET
查看在交互式调用期间构造了哪些参数。
replace.el
你会看到发现(如果你点击查看函数的源代码会更好C-h f perform-replace
),replacements
参数可以采用 (FUNCTION . ARGUMENT) 形式。更具体地说,该代码包含一个注释,提供了一些详细信息:
;; REPLACEMENTS is either a string, a list of strings, or a cons cell
;; containing a function and its first argument. The function is
;; called to generate each replacement like this:
;; (funcall (car replacements) (cdr replacements) replace-count)
;; It must return a string.