如何在 find-name-dired 中格式化正则表达式?

How to format regexes in find-name-dired?

调用 M-x find-name-dired 时,系统会提示您输入根目录和文件名模式。

多文件扩展名的正确查找正则表达式是什么?例如,使用 *(txt|html) 会转换为 find . \( -iname \*\(coffee\|html\) \) -ls,这是行不通的。有什么方法可以转换成这里提到的-o-regex

https://unix.stackexchange.com/questions/15308/how-to-use-find-command-to-search-for-multiple-extensions

?

-name 参数来自一个变量,因此可以很容易地在代码中覆盖它:

(defun my-find-regex-dired ()
  "Like `find-name-dired', but using -regex instead of -name"
  (interactive)
  (let ((find-name-arg "-regex"))
    (call-interactively 'find-name-dired)))

或者您可以复制 find-name-dired 并根据需要进行编辑。

但我建议只使用 M-x find-dired,这样您就可以完全控制参数。