【发布时间】:2017-10-09 17:40:45
【问题描述】:
我正在尝试做一些看似简单的事情:创建一个 Emacs 函数来为我创建一个 TAGS 文件。有这样做的简单说明here
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(eshell-command
(format "find %s -type f -name \"*.[ch]\" | etags -" dir-name)))
问题是我需要“cpp”文件而不是“c”。这意味着我的 find 命令必须更改为:
find %s -type f -iname "*.cpp" -or -iname "*.h"
这在命令行上效果很好。我遇到的问题是 eshell 似乎根本不喜欢那样。当我执行这个函数时,我不断得到:
File not found - "*.h": Invalid argument.
this question 的答案表明,正确使用 shell-quote-argument 可能会解决这些问题,但我无法找到可行的解决方案。例如,这会产生相同的错误:
(format "find %s -type f -iname %s -or -iname %s | etags -"
dir-name
(shell-quote-argument "*.cpp")
(shell-quote-argument "*.h"))
【问题讨论】:
-
使用更好的ctags 可能是最简单的解决方案。
-
您是否尝试过使用常规的
shell-command而不是eshell-command? -
@sds - 刚试过
shell-command。完全相同的结果。 -
可能 - 我的 emacs 是 26.0.50。你的(20.0.50)可能是一个错字。我不相信您使用的是 20 年前的 开发 版本。
-
@T.E.D.你在 Windows 中运行 find 吗?
标签: windows emacs find interactive-shell